Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Won't Fix
-
1.5.00
-
None
-
None
Description
public String toHex(byte[] digest)
{
StringBuffer buf = new StringBuffer();
for (int i = 0; i < digest.length; i++) {
buf.append(Integer.toHexString((int) digest[i] & 0x00FF));
}
return buf.toString();
}
public String getHashedPassword(String pass) throws Exception
{
MessageDigest md5 = MessageDigest.getInstance("MD5");
md5.update(pass.getBytes());
return toHex(md5.digest());
}
For example: The real MD5 for "demouser" vs PMUtil
md5('demouser')
91017d590a69dc49807671a51f10ab7f
PMUtil.getHashedPassword("demouser")
9117d59a69dc49807671a51f10ab7f
{
StringBuffer buf = new StringBuffer();
for (int i = 0; i < digest.length; i++) {
buf.append(Integer.toHexString((int) digest[i] & 0x00FF));
}
return buf.toString();
}
public String getHashedPassword(String pass) throws Exception
{
MessageDigest md5 = MessageDigest.getInstance("MD5");
md5.update(pass.getBytes());
return toHex(md5.digest());
}
For example: The real MD5 for "demouser" vs PMUtil
md5('demouser')
91017d590a69dc49807671a51f10ab7f
PMUtil.getHashedPassword("demouser")
9117d59a69dc49807671a51f10ab7f