1
2
3
4
5
6
7
8
9
10
11
12
13
14
public String createDigest(String source) {
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] data = source.getBytes();
md.update(data);
byte[] digest = md.digest();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < digest.length; i++) {
int b = (0xFF & digest\[i\]);
if (b < 16)
sb.append("0");
sb.append(Integer.toHexString(b));
}
return sb.toString();
}

※ご指摘のゼロ補完処理を追加(2012/2/25)