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 8155943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:48:42+00:00 2026-06-06T16:48:42+00:00

I have a cross-language problem regarding md5 :). I have this code in Java:

  • 0

I have a cross-language problem regarding md5 :).
I have this code in Java:

BASE64Encoder encoder = new BASE64Encoder();
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(someString.getBytes());
byte[] bMac = md.digest();
String anotherString = encoder.encodeBuffer(bMac);

This encodes and hashes a string in md5 and base64. A string like “aaa&1” becomes Fv4eRn4R0/mB+uc4j1GGaA==

Now the problem is: how to do this in C++? I’m using openssl/md5.h, but like any other online md5 encoder (after a small google search), it gets a hash like:
16fe1e467e11d3f981fae7388f518668

Which is in hex it seems. If I try to transform the md5 hash in base64, I get a completely different hash (longer and uglier 🙂 ).

Help!!!

Thank you!

L.E.: I use the MD5 method from openssl/md5.h, as AZI pointed out.

  • 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-06T16:48:43+00:00Added an answer on June 6, 2026 at 4:48 pm

    Here is the C++ code to obtain md5

    #include <openssl/md5.h>
    unsigned char *MD5(const unsigned char *d, 
                   unsigned long n,
                   unsigned char *md);
    

    example:

    unsigned char inbuf[] = "aaa&1";
    unsigned char outbuf[20];
    MD5(inbuf, strlen(inbuf), outbuf);
    
    for (i = 0; i < 20; i++) {
        printf("%02x ", outbuf[i]);
    }
    

    if Hex of 16fe1e467e11d3f981fae7388f518668 converted to Base64 then Hex to Base64 you will get Fv4eRn4R0/mB+uc4j1GGaA==

    May refer to Howto base64 encode with C/C++ and OpenSSL to encode this to Base64

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have code that relies heavily on yaml for cross-language serialization and while working
I have a cross-tab report which similar to this Problem is when there are
This is a cross language question on coding style. I have to work with
I have been trying to learn a cross platform language with a fast learning
I have found myself designing a language for fun that is a cross between
I have a project that use JSON as cross-language serialization to pass around data.
I'm trying to get PHP dates to work cross language. The language code will
I would like to have a cross platform framework as these platform solutions. My
I have designed a cross tab report in ireport4.0.1. because of cross tab i
I have a web page that uses cross page posting to post to a

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.