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 pData)
MD
MessageDigest md = null;
try {
    md = MessageDigest.getInstance("MD5");
    md.update(pData.getBytes());
} catch (NoSuchAlgorithmException e) {
    System.err.println("No such Algorithm!");
    return null;
byte[] digest = md.digest();
StringBuffer lStr = new StringBuffer();
for (int i = 0; i < digest.length; i++) {
    String s = Integer.toHexString(digest[i] & 0xFF);
    if (s.length() == 1)
        lStr.append("0");
    lStr.append(s);
return lStr.toString();
Stringmd5(String plain)
md
try {
    MessageDigest m = MessageDigest.getInstance("MD5");
    m.update(plain.getBytes(), 0, plain.length());
    String digest = new BigInteger(1, m.digest()).toString(16);
    return digest;
} catch (NoSuchAlgorithmException e) {
    throw new RuntimeException(e);
StringMd5(String plainText)
Md
StringBuffer buf = new StringBuffer("");
MessageDigest md;
try {
    md = MessageDigest.getInstance("MD5");
    md.update(plainText.getBytes());
    byte b[] = md.digest();
    int i;
    for (int offset = 0; offset < b.length; offset++) {
...
Stringmd5(String plainText)
md
String encryptText = null;
try {
    MessageDigest m = MessageDigest.getInstance("MD5");
    m.update(plainText.getBytes("UTF8"));
    byte s[] = m.digest();
    StringBuilder result = new StringBuilder();
    for (int i = 0; i < s.length; i++) {
        result.append(Integer.toHexString((0x000000FF & s[i]) | 0xFFFFFF00).substring(6));
...
StringMd5(String plainText)
Md
String result = null;
try {
    MessageDigest md = MessageDigest.getInstance("MD5");
    md.update(plainText.getBytes());
    byte b[] = md.digest();
    int i;
    StringBuffer buf = new StringBuffer("");
    for (int offset = 0; offset < b.length; offset++) {
...
Stringmd5(String plainText)
MD5
return md5(plainText.getBytes());
Stringmd5(String plainText)
md
String md5Text = null;
if (plainText != null) {
    try {
        byte[] byteArray = plainText.getBytes();
        MessageDigest md5 = MessageDigest.getInstance("MD5");
        md5.update(byteArray);
        byte[] md5Bytes = md5.digest();
        StringBuffer buf = new StringBuffer();
...
StringMD5(String pwd)
MD
if (pwd != null) {
    try {
        byte[] btInput = pwd.getBytes();
        MessageDigest mdInst = MessageDigest.getInstance("MD5");
        mdInst.update(btInput);
        byte[] md = mdInst.digest();
        int j = md.length;
        char[] str = new char[j * 2];
...
Stringmd5(String raw)
md
return digest(raw, "MD5");
Stringmd5(String s)
md
return digest(s, DIGEST_MD5);