public static String MD5(String text){
String md5Text = "";
try {
MessageDigest digest = MessageDigest.getInstance("MD5");
md5Text = new BigInteger(1,digest.digest((text).getBytes()))
.toString(16);
} catch (Exception e) {
System.out.println("Error in call to MD5");
}
if (md5Text.length() == 31) {
md5Text = "0" + md5Text;
}
return md5Text;
}
出處來自 Yahoo BBAuth 的開放碼
沒有留言:
張貼留言