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 text, String key)
md
byte[] bytes = (text + key).getBytes("utf-8");
MessageDigest messageDigest = MessageDigest.getInstance("MD5");
messageDigest.update(bytes);
bytes = messageDigest.digest();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < bytes.length; i++) {
    if ((bytes[i] & 0xff) < 0x10) {
        sb.append("0");
...
Stringmd5(String txt)
md
return hash("MD5", txt);
Stringmd5(String userPass)
md
java.security.MessageDigest md5 = java.security.MessageDigest.getInstance("MD5");
md5.update(userPass.getBytes());
byte b[] = md5.digest();
return new BigInteger(b).toString(16);
Stringmd5(String value)
md
return byte2hex(digest(value, MD5));
Stringmd5(String value)
md
if (value == null)
    value = "";
try {
    final MessageDigest digest = MessageDigest.getInstance("MD5");
    final byte[] buffer = value.getBytes("UTF-8");
    final byte[] digestBuffer = digest.digest(buffer);
    return new String(digestBuffer);
} catch (final Exception e) {
...
Stringmd5(String value)
Return the MD5 sum of a string valiue
try {
    MessageDigest m = MessageDigest.getInstance("MD5");
    byte[] data = value.getBytes();
    m.update(data, 0, data.length);
    BigInteger i = new BigInteger(1, m.digest());
    return String.format("%1$032x", i);
} catch (Exception e) {
    throw new RuntimeException("Failed to md5 value: " + value);
...
Stringmd5(String value)
md
try {
    byte[] bytes = value.getBytes("UTF-8");
    MessageDigest md = MessageDigest.getInstance("MD5");
    byte[] digest = md.digest(bytes);
    return Base64.getUrlEncoder().encodeToString(digest);
} catch (UnsupportedEncodingException | NoSuchAlgorithmException e) {
    throw new IllegalStateException("MD5 hash failed", e);
Stringmd5(String... args)
md
String tmp = joinStrings(args);
MessageDigest messageDigest = MessageDigest.getInstance("MD5");
messageDigest.reset();
messageDigest.update(tmp.getBytes(CHARSET));
byte[] byteArray = messageDigest.digest();
StringBuffer md5StrBuff = new StringBuffer();
for (int i = 0; i < byteArray.length; i++) {
    if (Integer.toHexString(0xFF & byteArray[i]).length() == 1) {
...
StringMD5(String... texts)
MD
try {
    if (texts == null || texts.length == 0)
        return null;
    MessageDigest messageDigest = MessageDigest.getInstance("MD5");
    for (String tt : texts)
        messageDigest.update(tt.getBytes());
    byte[] updateBytes = messageDigest.digest();
    int len = updateBytes.length;
...
Stringmd52(String string)
md
if (string == null || string.trim().length() < 1) {
    return null;
try {
    return getMD52(string.getBytes("UTF-8"));
} catch (UnsupportedEncodingException e) {
    throw new RuntimeException(e.getMessage(), e);