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 str)
md
MessageDigest md5 = null;
try {
    md5 = MessageDigest.getInstance("MD5");
} catch (Exception e) {
    e.printStackTrace();
    return "";
char[] charArray = str.toCharArray();
...
Stringmd5(String str)
md
try {
    MessageDigest md = MessageDigest.getInstance("MD5");
    md.update(str.getBytes());
    byte[] b = md.digest();
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < b.length; i++) {
        int v = (int) b[i];
        v = v < 0 ? 0x100 + v : v;
...
Stringmd5(String str)
md
return hexEncode(md5(str.getBytes()));
Stringmd5(String str)
md
MessageDigest md = null;
try {
    md = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
    e.printStackTrace();
md.update(str.getBytes());
byte byteData[] = md.digest();
...
Stringmd5(String str)
md
char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
MessageDigest md5 = null;
try {
    md5 = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
    e.printStackTrace();
    throw new RuntimeException(e.getMessage());
md5.update(str.getBytes());
byte[] encodedValue = md5.digest();
int j = encodedValue.length;
char finalValue[] = new char[j * 2];
int k = 0;
for (int i = 0; i < j; i++) {
    byte encoded = encodedValue[i];
    finalValue[k++] = hexDigits[encoded >> 4 & 0xf];
    finalValue[k++] = hexDigits[encoded & 0xf];
return new String(finalValue);
StringMD5(String str)
MD
return MD5(str.getBytes());
byte[]md5(String str)
Determine the message digest
try {
    MessageDigest md = getMessageDigest();
    return md.digest(str.getBytes(UTF8));
} catch (Exception e) {
    throw new RuntimeException(e);
byte[]md5(String str)
md
java.security.MessageDigest digest;
try {
    digest = java.security.MessageDigest.getInstance("MD5");
    return digest.digest(str.getBytes());
} catch (NoSuchAlgorithmException e) {
    e.printStackTrace();
return null;
...
Stringmd5(String str)
md
byte[] byteArray = null;
try {
    MessageDigest messageDigest = MessageDigest.getInstance("MD5");
    messageDigest.reset();
    messageDigest.update(str.getBytes("UTF-8"));
    byteArray = messageDigest.digest();
} catch (Exception e) {
    e.printStackTrace();
...
StringMD5(String str)
MD
try {
    if (isBlank(str)) {
        return null;
    MessageDigest md = java.security.MessageDigest.getInstance("MD5");
    md.update(str.getBytes("UTF-8"));
    byte tmp[] = md.digest();
    StringBuilder sb = new StringBuilder();
...