Java Utililty Methods MD5 String

List of utility methods to do MD5 String

Description

The list of methods to do MD5 String are organized into topic(s).

Method

Stringmd5(String d)
md
return md5(d.getBytes());
byte[]md5(String data)
Calculates the MD5 digest and returns the value as a 16 element byte[].
return md5(getBytesUtf8(data));
Stringmd5(String data)
Convert data to md5
try {
    MessageDigest md = MessageDigest.getInstance("MD5");
    md.update(data.getBytes());
    return bytesToHex(md.digest());
} catch (Exception ex) {
return "";
Stringmd5(String data)
md
try {
    MessageDigest md = MessageDigest.getInstance(MD);
    md.update(data.getBytes(UTF8));
    return encodeHex(md.digest());
} catch (Exception e) {
    throw new RuntimeException(e);
Stringmd5(String data)
Hashes a String using the MD5 algorithm and returns the result as a String of hexadecimal numbers.
return hash(data, MD5);
Stringmd5(String data)
md
return byte2hex(MessageDigest.getInstance("MD5").digest(data.getBytes()));
Stringmd5(String encryptStr)
md
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(encryptStr.getBytes("UTF-8"));
byte[] digest = md.digest();
StringBuffer md5 = new StringBuffer();
for (int i = 0; i < digest.length; i++) {
    md5.append(Character.forDigit((digest[i] & 0xF0) >> 4, 16));
    md5.append(Character.forDigit((digest[i] & 0xF), 16));
encryptStr = md5.toString();
return encryptStr;
StringMD5(String input)
MD
StringBuffer md5Hash = new StringBuffer(32);
try {
    byte[] b = MessageDigest.getInstance("MD5").digest(input.getBytes());
    int len = b.length;
    for (int x = 0; x < len; x++) {
        md5Hash.append(String.format("%02x", b[x]));
} catch (Exception e) {
...
Stringmd5(String input)
Create an MD5 Hash of an input String.
StringBuilder res = new StringBuilder();
try {
    MessageDigest algorithm = MessageDigest.getInstance("MD5");
    algorithm.reset();
    algorithm.update(input.getBytes());
    byte[] md5 = algorithm.digest();
    String tmp = "";
    for (int i = 0; i < md5.length; i++) {
...
Stringmd5(String input)
Return a string of 32 lower case hex characters.
String hexHash = null;
try {
    MessageDigest md = MessageDigest.getInstance("MD5");
    md.update(input.getBytes());
    byte[] output = md.digest();
    hexHash = bytesToLowerCaseHex(output);
} catch (NoSuchAlgorithmException nsae) {
    throw new RuntimeException(nsae);
...