My client wants to convert a string into MD5 and then get it base64 encoded. At his side, using some methods in C library, he did encoding as follows
plain text is siddhesh
base64: nKV0sXokS6DYA24Th68fKw== (len=24)
Using Java Base64 class, I am not able to get value of "9ca574b17a244ba0d8036e1387af1f2b" as "nKV0sXokS6DYA24Th68fKw==".
I am getting larger value like "OWNhNTc0YjE3YTI0NGJhMGQ4MDM2ZTEzODdhZjFmMmI=" and same is the value when I do encoding using any online converter.
Any inputs on how to user Base64 class or some other technique with Java to get the Value as above in length of 24
Good, Better, Best, Don't take rest until, Good becomes Better, and Better becomes Best.
Sidd : (SCJP 6 [90%] )
Siddhesh Deodhar wrote:My client wants to convert a string into MD5 and then get it base64 encoded.
That's most likely your problem right there. Because the purpose of Base64 encoding is to convert an array of bytes into an encoded string. It would help to see your code, but my guess is that at some point you're taking an array of bytes and illegitimately converting it to a String.
Are you converting the actual MD5 byte values, or the String representation of those bytes? For instance the String value "F0" (2 characters) is different from the byte value 0xF0 (8 bits).
Edit: didn't see your response there Paul, when I wrote this. Basically you're hinting the same...