Skip to content

Latest commit

 

History

History
22 lines (21 loc) · 514 Bytes

File metadata and controls

22 lines (21 loc) · 514 Bytes

加解密相关

MD5加密

/**
* MD5加密
*/
public static String encryptMD5(String data) throws Exception {
    MessageDigest md5 = MessageDigest.getInstance("MD5");
    return new BigInteger(md5.digest(data.getBytes())).toString(16);
}

SHA加密

/**
* SHA加密
*/
public static String encryptSHA(String data) throws Exception {
    MessageDigest sha = MessageDigest.getInstance("SHA");
    return new BigInteger(sha.digest(data.getBytes())).toString(32);
}