0
iQi - 面白いアプリを開発中
public static String md5(String str) {
try {
// Create MD5 Hash
MessageDigest digest = java.security.MessageDigest.getInstance("MD5");
digest.update(str.getBytes());
byte messageDigest[] = digest.digest();
// Create md5 String
StringBuffer md5String = new StringBuffer();
for (int i=0; i<messageDigest.length; i++){
String h = Integer.toHexString(0xFF & messageDigest[i]);
while (h.length() < 2){
h = "0" + h;
}
md5String.append(h);
}
System.out.println(str + ":" + md5String.toString());
return md5String.toString();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return "";
}