Hey all,
I want to store passwords in a postgresql database. Currently I use the
MD5Password class below and I've been developing on windows. I ran into
problems when running my application on linux.
Linux and Windows, with same JDK's (1.5.0), create different encrypted
password strings. So when testing a password created on one platform on
the other, it will fail :(
Is there a way to make the getEncodedPassw ord method behave the same
regardless of the application being run on windows or linux? And if not,
how could I facilitate platform-independent, easy, not necesarily strong
password encryption?
Thanks in advance for any suggestions,
Ronald
--------------------------------------------------
import java.security.* ;
public class MD5Password {
public static String getEncodedPassw ord(String clearTextPasswo rd)
throws
NoSuchAlgorithm Exception {
MessageDigest md = MessageDigest.g etInstance("MD5 ");
md.update(clear TextPassword.ge tBytes());
return new String(md.diges t());
}
public static boolean testPassword(St ring clearTextTestPa ssword,
String encodedActualPa ssword) throws
NoSuchAlgorithm Exception {
String encodedTestPass word = MD5Password.get EncodedPassword (
clearTextTestPa ssword);
return (encodedTestPas sword.equals(en codedActualPass word));
}
}
--------------------------------------------------
I want to store passwords in a postgresql database. Currently I use the
MD5Password class below and I've been developing on windows. I ran into
problems when running my application on linux.
Linux and Windows, with same JDK's (1.5.0), create different encrypted
password strings. So when testing a password created on one platform on
the other, it will fail :(
Is there a way to make the getEncodedPassw ord method behave the same
regardless of the application being run on windows or linux? And if not,
how could I facilitate platform-independent, easy, not necesarily strong
password encryption?
Thanks in advance for any suggestions,
Ronald
--------------------------------------------------
import java.security.* ;
public class MD5Password {
public static String getEncodedPassw ord(String clearTextPasswo rd)
throws
NoSuchAlgorithm Exception {
MessageDigest md = MessageDigest.g etInstance("MD5 ");
md.update(clear TextPassword.ge tBytes());
return new String(md.diges t());
}
public static boolean testPassword(St ring clearTextTestPa ssword,
String encodedActualPa ssword) throws
NoSuchAlgorithm Exception {
String encodedTestPass word = MD5Password.get EncodedPassword (
clearTextTestPa ssword);
return (encodedTestPas sword.equals(en codedActualPass word));
}
}
--------------------------------------------------
Comment