1) Convert the Perl md5 from byte to hex
2) Convert the Java md5 from byte to hex (examples here)
3) Compare the outputs
This is the Java code for the MD5 and convertion in Hex:
import java.security.MessageDigest;
public class HelloWorld
{
public static void main(String[] args)
{
System.out.println("Start");
String res=MD5("35799510369");
System.out.print("res:"+res);
}
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;
}
}//end MD5()
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();
}// end getString()
Copy and Paste the previus code in this online compiler and press COMPILE AND EXECUTE; next compare this output with the Perl md5 online script output.
For input=35799510369
Md5 digest is .S<ë_»X³ëE&â®
The hexadecimal representation of the digest is: 012e533c9aeb5f96bb58b3eb4526e2ae
res:012e533c9aeb5f96bb58b3eb4526e2ae
Good luck