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

Stringmd5Hex(String str)
md Hex
if (str == null) {
    return null;
StringBuffer hexStrSb = new StringBuffer();
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] hash = md.digest(str.getBytes());
for (int i = 0; i < hash.length; i++) {
    if ((0xff & hash[i]) < 0x10) {
...
byte[]md5raw(String data)
mdraw
try {
    MessageDigest md = MessageDigest.getInstance(MD);
    md.update(data.getBytes(UTF8));
    return md.digest();
} catch (Exception e) {
    throw new RuntimeException(e);
Stringmd5Representation(String data)
Returns a md5 representation of the given string
try {
    MessageDigest messageDigest = MessageDigest.getInstance("MD5");
    byte[] digest = messageDigest.digest(data.getBytes("US-ASCII"));
    return byteArrayToString(digest);
} catch (NoSuchAlgorithmException nsae) {
    throw new RuntimeException("No MD5 algorithm");
} catch (UnsupportedEncodingException e) {
    throw new RuntimeException("No UTF-8");
...
Stringmd5Signature(TreeMap params, String secret)
md Signature
String result = null;
StringBuffer orgin = getBeforeSign(params, new StringBuffer(secret));
if (orgin == null)
    return result;
orgin.append(secret);
try {
    MessageDigest md = MessageDigest.getInstance("MD5");
    result = byte2hex(md.digest(orgin.toString().getBytes("utf-8")));
...
Stringmd5Signature(TreeMap params, String secret)
md Signature
String result = null;
StringBuffer orgin = null;
try {
    orgin = getBeforeSign(params, new StringBuffer(secret));
} catch (UnsupportedEncodingException e1) {
    throw new java.lang.RuntimeException("sign encode error !");
if (orgin == null)
...
Stringmd5String(String input)
MD5 hashes the given input string and returns the hex digest in String form.
String result = "";
MessageDigest algorithm;
try {
    algorithm = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
    throw new RuntimeException(e);
algorithm.reset();
...
Stringmd5String(String key)
md String
byte[] messageDigest = md5(key);
return toHex(messageDigest);
Stringmd5String(String paramString)
md String
try {
    MessageDigest localMessageDigest = MessageDigest.getInstance("MD5");
    localMessageDigest.update(paramString.getBytes("UTF-8"), 0, paramString.length());
    String str = toHexString(localMessageDigest.digest());
    return str;
} catch (Exception localException) {
return "";
...
Stringmd5String(String s)
md String
try {
    MessageDigest messagedigest = MessageDigest.getInstance("MD5");
    byte abyte0[] = s.getBytes();
    abyte0 = messagedigest.digest(abyte0);
    StringBuffer stringbuffer = new StringBuffer(32);
    for (int i = 0; i < abyte0.length; i++) {
        String s1 = Integer.toHexString(abyte0[i] & 0xff);
        if (s1.length() == 1)
...
Stringmd5String(String s)
md String
byte messageDigest[] = md5Bytes(s);
if (messageDigest == null) {
    return "";
return hashToString(messageDigest);