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(final String string)
Get the md5 hash of a string.
return md5HashString(string);
Stringmd5(final String text)
md
try {
    final byte[] bytesOfMessage = text.getBytes("UTF-8");
    final MessageDigest md = MessageDigest.getInstance("MD5");
    final byte[] digest = md.digest(bytesOfMessage);
    return new String(digest);
} catch (Exception e) {
    throw new RuntimeException();
Stringmd5(InputStream input)
md
try {
    return digest(input, "MD5");
} catch (NoSuchAlgorithmException e) {
    throw new RuntimeException(e);
Stringmd5(InputStream is)
md
MessageDigest digest = MessageDigest.getInstance("MD5");
byte[] buffer = new byte[8192];
int read = 0;
while ((read = is.read(buffer)) > 0) {
    digest.update(buffer, 0, read);
byte[] md5sum = digest.digest();
BigInteger bigInt = new BigInteger(1, md5sum);
...
Stringmd5(java.lang.String message)
Creates an MD5 digest from the message.
try {
    MessageDigest md = MessageDigest.getInstance("MD5");
    StringBuilder sb = new StringBuilder();
    byte buf[] = message.getBytes();
    byte[] md5 = md.digest(buf);
    for (byte aMd5 : md5) {
        String tmpStr = "0" + Integer.toHexString((0xff & aMd5));
        sb.append(tmpStr.substring(tmpStr.length() - 2));
...
Stringmd5(Object content)
md
String keys = null;
if (content == null) {
    return null;
try {
    MessageDigest md = MessageDigest.getInstance(MD5_NAME);
    byte[] bPass = String.valueOf(content).getBytes(CARTSET_UTF_8);
    md.update(bPass);
...
byte[]md5(Path path)
md
byte[] buf = new byte[1024];
MessageDigest complete = MessageDigest.getInstance("MD5");
int read;
try (InputStream is = Files.newInputStream(path)) {
    do {
        read = is.read(buf);
        if (read > 0) {
            complete.update(buf, 0, read);
...
Stringmd5(String content)
md
try {
    MessageDigest md = MessageDigest.getInstance("MD5");
    byte[] thedigest = md.digest(content.getBytes());
    char chars[] = new char[16 * 2];
    for (int i = 0; i < thedigest.length; i++) {
        chars[i * 2] = hexDigits[thedigest[i] >>> 4 & 0xf];
        chars[i * 2 + 1] = hexDigits[thedigest[i] & 0xf];
    return new String(chars);
} catch (NoSuchAlgorithmException e) {
    e.printStackTrace();
return null;
Stringmd5(String content)
md
if (content == null) {
    return null;
String md5 = null;
try {
    MessageDigest mdEnc = MessageDigest.getInstance("MD5");
    mdEnc.update(content.getBytes(), 0, content.length());
    md5 = new BigInteger(1, mdEnc.digest()).toString(16);
...
Stringmd5(String content)
md
return base64en.encode(md5.digest(content.getBytes("utf-8")));