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 message)
md
try {
    MessageDigest md = MessageDigest.getInstance("MD5");
    return new String(md.digest(message.getBytes("CP1252")));
} catch (NoSuchAlgorithmException e) {
} catch (UnsupportedEncodingException e) {
return null;
StringMD5(String message)
MD
MessageDigest messageDigest = null;
try {
    messageDigest = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
    throw new RuntimeException("MD5 encryption not available.", e);
byte[] messageBytes;
try {
...
Stringmd5(String message)
md
try {
    MessageDigest digest = MessageDigest.getInstance("MD5");
    byte[] buffer = message.getBytes("UTF-8");
    digest.update(buffer);
    return encodeHex(digest.digest());
} catch (NoSuchAlgorithmException e) {
    throw new RuntimeException(e.getMessage());
} catch (UnsupportedEncodingException e) {
...
StringMD5(String message)
MD
try {
    MessageDigest m = MessageDigest.getInstance("MD5");
    m.update(message.getBytes());
    byte[] digest = m.digest();
    BigInteger bigInt = new BigInteger(1, digest);
    String hash = bigInt.toString(16);
    while (hash.length() < 32) {
        hash = "0" + hash;
...
Stringmd5(String orgin)
md
try {
    MessageDigest md = MessageDigest.getInstance("MD5");
    String result = byte2hex(md.digest(orgin.toString().getBytes("utf-8")));
    return result;
} catch (Exception e) {
    throw new java.lang.RuntimeException("sign error !");
Stringmd5(String pass)
md
String md5 = "";
try {
    MessageDigest m = MessageDigest.getInstance("MD5");
    byte[] data = pass.getBytes();
    m.update(data, 0, data.length);
    BigInteger i = new BigInteger(1, m.digest());
    md5 = String.format("%1$032x", i);
} catch (NoSuchAlgorithmException e) {
...
Stringmd5(String password)
md
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(password.getBytes());
return new BigInteger(1, md.digest()).toString(16);
Stringmd5(String password)
md
String pass = "";
MessageDigest md = null;
try {
    md = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
    e.printStackTrace();
BigInteger hash = new BigInteger(1, md.digest(password.getBytes()));
...
Stringmd5(String password)
md
byte[] uniqueKey = password.getBytes(Charset.forName("UTF-8"));
byte[] hash = null;
try {
    hash = MessageDigest.getInstance("MD5").digest(uniqueKey);
} catch (NoSuchAlgorithmException e) {
    throw new Error("No MD5 support in this VM.");
StringBuilder hashString = new StringBuilder();
...
Stringmd5(String path_of_file_)
md
try {
    MessageDigest md = MessageDigest.getInstance("MD5");
    InputStream is = Files.newInputStream(Paths.get(path_of_file_));
    DigestInputStream dis = new DigestInputStream(is, md);
    byte[] buffer = new byte[8192];
    while (dis.read(buffer) > 0)
        ; 
    BigInteger bigInt = new BigInteger(1, md.digest());
...