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); } }
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/15926.html