package com.gmj.reflect;
import java.security.MessageDigest;
import sun.misc.BASE64Encoder;
public class MD5Util
{
public static String md5(String str)
{
try
{
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] b1 = md.digest(str.getBytes());
// BASE64Encoder encoder = new BASE64Encoder();
// return encoder.encode(b1);
return hex(b1);
}
catch (Exception e)
{
return null;
}
}
private static String hex(byte[] arr) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < arr.length; ++i) {
sb.append(Integer.toHexString((arr[i] & 0xFF) | 0x100).substring(1,3));
}
return sb.toString();
}
public static void main(String[] args)
{
System.out.println(md5("111111"));
}
}
MD5 32位加密
最新推荐文章于 2024-04-05 10:30:00 发布