标签:cat key family runtime hmac span init encode spec
Java HmacSHA1算法
public static String hmacSha1(String src, String key) { try { SecretKeySpec signingKey = new SecretKeySpec(key.getBytes("utf-8"), "HmacSHA1"); Mac mac = Mac.getInstance("HmacSHA1"); mac.init(signingKey); byte[] rawHmac = mac.doFinal(src.getBytes("utf-8")); return Hex.encodeHexString(rawHmac); } catch (Exception e) { throw new RuntimeException(e); } }
标签:cat key family runtime hmac span init encode spec
原文地址:https://www.cnblogs.com/frankyou/p/9139374.html