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

  • SEARCH
  • Home
  • 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 258537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:11:20+00:00 2026-05-11T22:11:20+00:00

The next function in MySQL MD5( ‘secret’ ) generates 5ebe2294ecd0e0f08eab7690d2a6ee69 I would like to

  • 0

The next function in MySQL

MD5( 'secret' ) generates 5ebe2294ecd0e0f08eab7690d2a6ee69

I would like to have a Java function to generate the same output. But

public static String md5( String source ) {
    try {
        MessageDigest md = MessageDigest.getInstance( "MD5" );
        byte[] bytes = md.digest( source.getBytes("UTF-8") );
        return getString( bytes );
    } catch( Exception e )  {
        e.printStackTrace();
        return null;
    }
}

private static String getString( byte[] bytes ) {
    StringBuffer sb = new StringBuffer();
    for( int i=0; i<bytes.length; i++ ) {
        byte b = bytes[ i ];
        sb.append( ( int )( 0x00FF & b ) );
        if( i+1 <bytes.length ) {
            sb.append( "-" );
        }
    }
    return sb.toString();
}

generates

94-190-34-148-236-208-224-240-142-171-118-144-210-166-238-105
  • 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-05-11T22:11:20+00:00Added an answer on May 11, 2026 at 10:11 pm

    Try encoding in base 16. Just to get you started… 94 in base 16 is 5E.

    **Edit:**Try changing your getString method:

    private static String getString( byte[] bytes ) 
    {
      StringBuffer sb = new StringBuffer();
      for( int i=0; i<bytes.length; i++ )     
      {
         byte b = bytes[ i ];
         String hex = Integer.toHexString((int) 0x00FF & b);
         if (hex.length() == 1) 
         {
            sb.append("0");
         }
         sb.append( hex );
      }
      return sb.toString();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I have next function, what always return null as result, but service calling
I have coded the next function. But surely someone has a more elegant way
I have next function for autocomplete an input: $(#auto).autocomplete({ source:/autocomplete.php, minLength: 5, _renderItem: function(
I have the next code: js: $('[id^=check-]').change(function(){ var new_id = this.id.replace(/check/, 'new'), real_id =
So I have this function that takes all the users from an MySql table
I have the following PHP function which will list the users from a MySql
I have function which selects data from MySQL database: function get_articles( $id ){ global
I have problem with ajax and php.I have next code $(form).submit(function() { var poruka
I have written the following function in Java. This function returns current timestamp by
In module on some site i have next code function q_cart_add($node) { global $user;

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.