Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8623123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:12:39+00:00 2026-06-12T07:12:39+00:00

I have a java code base that generates an URL safe base64 encoded hash

  • 0

I have a java code base that generates an URL safe base64 encoded hash from a string, and wondering if / how this would be possible with linux command line tools. I’m guessing the problem with what I am doing here is with the character set / encoding or to do with converting the string to a byte array. Java code:

MessageDigest md = MessageDigest.getInstance("SHA-256");
byte[] digest = md.digest("testString".getBytes());
// ^^ this is where the difference is?
String b64url = Base64.encodeBase64URLSafeString(digest);
// b64url: Ss8LOdnEdmcJo2ifVTrAGrVQVF_6RUTfwLLOqC-6AqM

Command line:

echo testString | sha256sum | cut -d" " -f1 | base64
# NDgxOGEyY2JkODYwOTY1NjJkODFmYzIwNmQ3ZTYyNWVlNGFjMTU5MmViNTc0MjQwMDQ4OTIzOTBl
# MDQzZTNlYwo=

Is it possible to generate base64 encoded sha256 via cli tools?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T07:12:40+00:00Added an answer on June 12, 2026 at 7:12 am

    You’re base64 encoding a hexadecimal string, not the byte values of the hash, which is the equivalent of:

    MessageDigest md = MessageDigest.getInstance("SHA-256");
    byte[] digest = md.digest("testString".getBytes()); // Missing charset
    String hex = Hex.encodeHexString(digest);
    String base64 = Base64.encodeBase64(hex.getBytes());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a complete Java based code base, where members are named: String m_sFoo;
We have a C# code base that we have to deploy on Java. We
I already have Java code to display and process data from a database. I
In my source tree have Java code which is automatically generated from XSD files.
i have this java code: ArrayList<MessageMap> ids = getNewMail(UserID, type, maxIdMessage); Message[] message =
We have a large java code base [~1 M Lines]. Buried (somewhere) in the
Have an existing C# .NET code base that is currently coded to directly access
I'm maintaing an older Java code base (jvm 1.4) that seems to use cloning
Disclaimer: I apologize that this question is so long. I have added code as
Let's say you have some Java code as follows: public class Base{ public void

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.