Hi there!
I'm searching for a solution of the following problem: In my code, i generate the md5 hash for a password. This String is compared with an entry in a mysql database. The useradministration is php-based, so the md5 hashes of the passwords in the database are generated with PHP. Something like that:
(<?php md5($pw); ?>)
Now, my source of the hasher looks like that:
private static String md5(String string) {
MessageDigest md = null;
try {
md = MessageDigest.getInstance("MD5");
md.update(string.getBytes("UTF-8"));
String hash = (new BASE64Encoder()).encode(md.digest());
System.out.println(hash);
return hash;
} catch (Exception e) {
System.out.println(e.getMessage());
return null;
}
}
The problem is: the two implementations (PHP and mine, or the MD of java, whatever) return different results.
Examples:
"Wayne"
Java: Q91UYeoJCxEVpOqrTufIDg==
PHP: 43dd5461ea090b1115a4eaab4ee7c80e
"test"
Java: CY9rzUYh03PK3k6DJie09g==
PHP: 098f6bcd4621d373cade4e832627b4f6
Does anybody of you see the mistake I made or has an Idea how to fix this problem?
Greetings and thx
commy