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)
MD
MessageDigest md;
md = MessageDigest.getInstance("MD5");
byte[] md5hash = new byte[32];
md.update(text.getBytes("iso-8859-1"), 0, text.length());
md5hash = md.digest();
return convertToHex(md5hash);
StringMD5(String text)
MD
try {
    MessageDigest md = MessageDigest.getInstance("MD5");
    byte[] md5hash = new byte[32];
    md.update(text.getBytes("iso-8859-1"), 0, text.length());
    md5hash = md.digest();
    return convertToHex(md5hash);
} catch (Exception e) {
return null;
StringMD5(String text)
MD
return messageDigest(text, "MD5");
Stringmd5(String text)
Encrypt String
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] b = md.digest(text.getBytes());
int size = b.length;
StringBuffer encryptStr = new StringBuffer(size);
for (int i = 0; i < size; i++) {
    int u = b[i] & 255;
    if (u < 16) {
        encryptStr.append("0" + Integer.toHexString(u));
...
Stringmd5(String text)
returning a MD5 hash string
try {
    if (text == null) {
        return "";
    byte[] digest = MessageDigest.getInstance("MD5").digest(text.getBytes());
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < digest.length; i++) {
        sb.append(Integer.toString((digest[i] & 0xf0) >> 4, 16));
...
StringMD5(String text)
This nethod is used for encrypt String to MD5
String output = null;
try {
    MessageDigest dg = MessageDigest.getInstance("MD5");
    dg.reset();
    dg.update(stringToBytes(text));
    byte[] hasher = new byte[32];
    hasher = dg.digest();
    return bytesToHexString(hasher);
...
Stringmd5(String text)
md
byte[] bytes = md.digest(text.getBytes());
BigInteger bi = new BigInteger(bytes);
return bi.toString(16);
Stringmd5(String text)
md
try {
    return hash("MD5", text);
} catch (Exception e) {
    throw new RuntimeException(e);
Stringmd5(String text)
md
MessageDigest msgDigest = null;
try {
    msgDigest = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
    throw new IllegalStateException("System doesn't support MD5 algorithm.");
try {
    msgDigest.update(text.getBytes("utf-8"));
...
byte[]md5(String text, String charset)
Computes an md5 hash of a string.
if (text == null) {
    throw new NullPointerException("null text"); 
try {
    MessageDigest md = MessageDigest.getInstance("MD5"); 
    md.update(text.getBytes(charset));
    return md.digest();
} catch (NoSuchAlgorithmException e) {
...