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_HEX(String source)
MHEX
try {
    return digest("MD5", source);
} catch (NoSuchAlgorithmException ignore) {
return null;
Stringmd5AsHexString(String text, String charset)
Computes an md5 hash and returns the result as a string in hexadecimal format.
return toHexString(md5(text, charset));
Stringmd5Base64(String str)
md Base
try {
    MessageDigest md5 = MessageDigest.getInstance("MD5");
    return base64Encode(md5.digest(str.getBytes()));
} catch (NoSuchAlgorithmException e) {
    e.printStackTrace();
return null;
Stringmd5ByHex(String src)
md By Hex
try {
    MessageDigest md = MessageDigest.getInstance("MD5");
    byte[] b = src.getBytes();
    md.reset();
    md.update(b);
    byte[] hash = md.digest();
    String hs = "";
    String stmp = "";
...
Stringmd5crypt(String s)
mdcrypt
System.out.println(s);
digestBuffer.setLength(0);
byte abyte0[] = md5.digest(s.getBytes());
for (int i = 0; i < abyte0.length; i++)
    digestBuffer.append(toHex(abyte0[i]));
return digestBuffer.toString();
byte[]md5Digest(final InputStream data)
md Digest
MessageDigest digest = getMD5MessageDigest();
updateMessageDigest(digest, data);
return digest.digest();
Stringmd5Digest(final String message)
md Digest
String digest;
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] hash = md.digest(message.getBytes("UTF-8"));
StringBuilder sb = new StringBuilder(2 * hash.length);
for (byte b : hash) {
    sb.append(String.format("%02x", b & 0xff));
digest = sb.toString();
...
byte[]md5digest(String key)
mddigest
if (key == null) {
    return null;
MessageDigest md5;
try {
    md5 = (MessageDigest) md5Digest.clone();
} catch (CloneNotSupportedException e) {
    throw new RuntimeException("clone of MD5 not supported", e);
...
byte[]md5Digest(String s)
md Digest
try {
    MessageDigest digest = java.security.MessageDigest.getInstance("MD5");
    byte[] actual = digest.digest(s.getBytes("UTF-8"));
    return actual;
} catch (UnsupportedEncodingException ex) {
    throw new RuntimeException(ex);
} catch (NoSuchAlgorithmException ex) {
    throw new RuntimeException(ex);
...
byte[]md5Digest(String text)
md Digest
return digest(MD5_ALGORITHM_NAME, text.getBytes());