我发现这段代码返回给定字符串的校验和。
public static String getChecksum(String md5) {
int counter = 0;
while (counter != 2) {
try {
java.security.MessageDigest md = java.security.MessageDigest
.getInstance("MD5");
byte[] array = md.digest(md5.getBytes());
StringBuffer sb = new StringBuffer();
for (int i = 0; i < array.length; ++i) {
sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100)
.substring(1, 3));
}
return sb.toString();
} catch (java.security.NoSuchAlgorithmException e) {
continue;
}
}
return null;
}
我现在想做相反的事情——即给定校验和,取回原始字符串。这怎么可能?