Java MD5 String md5String(String paramString)

Here you can find the source of md5String(String paramString)

Description

md String

License

Open Source License

Declaration

public static String md5String(String paramString) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.security.MessageDigest;

public class Main {
    private static final char[] HEX_DIGITS = { 48, 49, 50, 51, 52, 53, 54,
            55, 56, 57, 97, 98, 99, 100, 101, 102 };

    public static String md5String(String paramString) {
        try {/*from   ww  w  . jav  a 2s  .  c  o m*/
            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 "";
    }

    public static String toHexString(byte[] paramArrayOfByte) {
        if (paramArrayOfByte == null)
            return "";
        StringBuilder localStringBuilder = new StringBuilder(
                paramArrayOfByte.length << 1);
        for (int i = 0;; i++) {
            if (i >= paramArrayOfByte.length)
                return localStringBuilder.toString();
            localStringBuilder
                    .append(HEX_DIGITS[((0xF0 & paramArrayOfByte[i]) >>> 4)]);
            localStringBuilder
                    .append(HEX_DIGITS[(0xF & paramArrayOfByte[i])]);
        }
    }
}

Related

  1. md5Representation(String data)
  2. md5Signature(TreeMap params, String secret)
  3. md5Signature(TreeMap params, String secret)
  4. md5String(String input)
  5. md5String(String key)
  6. md5String(String s)
  7. md5String(String s)
  8. MD5String(String str)
  9. MD5StringToL32(String md5Str)