public class MD5Utils {
/**
* 32位MD5加密
* @param content -- 待加密内容
* @return
*/
public static String md5Decode32(String content) {
byte[] hash;
try {
hash = MessageDigest.getInstance("MD5").digest(content.getBytes("UTF-8"));
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException("NoSuchAlgorithmException",e);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("UnsupportedEncodingException", e);
}
//对生成的16字节数组进行补零操作
StringBuilder hex = new StringBuilder(hash.length * 2);
for (byte b : hash) {
if ((b & 0xFF) < 0x10){
hex.append("0");
}
hex.append(Integer.toHexString(b & 0xFF));
}
return hex.toString().substring(6 , 26);
}
}
32位MD5加密工具类 安卓
最新推荐文章于 2023-06-16 18:18:40 发布