android MD5加密函数(32位小写)

来源:互联网 发布:java web项目权限控制 编辑:程序博客网 时间:2024/06/04 19:19
public static String getMd5Value(String sSecret) {
try {
MessageDigest bmd5 = MessageDigest.
getInstance("MD5");
bmd5.update(sSecret.getBytes());
int i;
StringBuffer buf =
 new StringBuffer();
byte[] b = bmd5.digest();
for (int offset = 0; offset < b.length; offset++) {
i = b[offset];
if (i < 0)
i += 256;
if (i < 16)
buf.append(
"0");
buf.append(Integer.
toHexString(i));
}
return buf.toString();
}
 catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return "";
}

16位小写加密只需getMd5Value("xxx").substring(8, 24);即可
原创粉丝点击