Java MD5 String md5Util(String password)

Here you can find the source of md5Util(String password)

Description

md Util

License

Apache License

Declaration

public static String md5Util(String password) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;

public class Main {

    public static String md5Util(String password) {
        MessageDigest messageDigest = null;
        try {/*from  w w  w  . j a  va2  s .c  om*/
            messageDigest = MessageDigest.getInstance("md5");
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        messageDigest.update(password.getBytes());
        byte[] data = messageDigest.digest();
        StringBuffer sb = new StringBuffer();
        for (byte b : data) {
            int bt = b & 0xff;
            if (bt < 16) {
                sb.append("0");
            }
            sb.append(Integer.toHexString(bt));
        }
        HashMap<String, String> map = new HashMap<String, String>(20, 0.75f);
        map.put(null, "test");
        return sb.toString();
    }
}

Related

  1. md5String(String s)
  2. md5String(String s)
  3. MD5String(String str)
  4. MD5StringToL32(String md5Str)
  5. MD5ToInt(String s)