Use UTF-8 when converting password strings to bytes for hashing to MD5.

This commit is contained in:
Michael Jumper
2013-01-29 13:59:41 -08:00
committed by Michael Jumper
parent 958eedb76b
commit 30e786e589

View File

@@ -1,5 +1,6 @@
package net.sourceforge.guacamole.net.basic.auth;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Map;
@@ -195,9 +196,12 @@ public class Authorization {
// Compare hashed password
try {
MessageDigest digest = MessageDigest.getInstance("MD5");
String hashedPassword = getHexString(digest.digest(password.getBytes()));
String hashedPassword = getHexString(digest.digest(password.getBytes("UTF-8")));
return hashedPassword.equals(this.password.toUpperCase());
}
catch (UnsupportedEncodingException e) {
throw new UnsupportedOperationException("Unexpected lack of UTF-8 support.", e);
}
catch (NoSuchAlgorithmException e) {
throw new UnsupportedOperationException("Unexpected lack of MD5 support.", e);
}