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.
Here is the C++ code to obtain md5
example:
if Hex of
16fe1e467e11d3f981fae7388f518668converted to Base64 then Hex to Base64 you will getFv4eRn4R0/mB+uc4j1GGaA==May refer to Howto base64 encode with C/C++ and OpenSSL to encode this to Base64