static String makeEncodedValue(String value) {
try {
MessageDigest digester =
MessageDigest.getInstance("MD5");
byte[] digest = digester.digest(
value.getBytes());
StringBuffer buf = new StringBuffer();
for (int i=0; i < digest.length; i++) {
int nValue = ((int) digest[i]) & 0xFF;
buf.append(Integer.toHexString(nValue));
}
return buf.toString();
} catch (NoSuchAlgorithmException e) {
// ... must.. do.. error.. recovery..
}
return value;
}
Oh..
import md5
def makeEncodedValue(value):
return md5.md5(value).hexdigest()
Time for coffee.
No comments:
Post a Comment