Commit c4d623d0 authored by Quxl's avatar Quxl

x

parent e8694dbb
......@@ -926,6 +926,18 @@ public class StringUtil {
}
}
public static String toHMACSHA256String(String encryptText, String encryptKey) {
try {
SecretKey secretKey = new SecretKeySpec(encryptKey.getBytes(), "HmacSHA256");
Mac mac = Mac.getInstance(secretKey.getAlgorithm());
mac.init(secretKey);
byte[] bs = mac.doFinal(encryptText.getBytes());
return Base64.encodeBase64String(bs);
} catch (Exception e) {
throw new SHA1Exception(e);
}
}
public static String toMD5HexString(String text) {
try {
return StringUtil.encodeHexString(MessageDigest.getInstance("MD5").digest(text.getBytes())).toUpperCase();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment