Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Different results with MessageDigest on different machines

843810Sep 5 2002 — edited May 27 2004
Hi all, please can somebody give advice on this...

I get different results from hashing a password using the same code, but on different machines:

Machine 1: Windows 2000, US English version, java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode))

password: P/vNwCWGJvy4ofo0WKW9Kw==

Machine 2: Windows 2000 Korean version, java version "1.4.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0_01-b03)
Java HotSpot(TM) Client VM (build 1.4.0_01-b03, mixed mode)

password: P/vNPz/8uKH6NFg/Kw==

Please note the different results of the hashed password.

Here is the code I use:
MessageDigest sha = null;
try {
sha = MessageDigest.getInstance("MD5");
}
catch (NoSuchAlgorithmException e) {
LoggingManager.error(this, "Exception: ", e);
}
byte[] tmp = password.getBytes();
sha.update(tmp);
com.sun.net.ssl.internal.www.protocol.https.BASE64Encoder b64Enc = new com.sun.net.ssl.internal.www.protocol.https.BASE64Encoder();
String md5enc = new String(sha.digest());
String encodedPassword = b64Enc.encodeBuffer(md5enc.getBytes());

Whats the reason for the different results and how can I overcome this problem`

Thanks for your help in advance!

Bernd
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 24 2004
Added on Sep 5 2002
7 comments
338 views