Skip to content

Instantly share code, notes, and snippets.

/hmac.java Secret

Created August 5, 2015 02:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/23f2597b19da01f36297 to your computer and use it in GitHub Desktop.
Save anonymous/23f2597b19da01f36297 to your computer and use it in GitHub Desktop.
private String generateHMAC(String data) throws Exception {
HMAC = Mac.getInstance("HmacSHA512");
SecretKeySpec secret = new SecretKeySpec(privKey.getBytes(),"HmacSHA512");
HMAC.init(secret);
byte[] hmac_data = HMAC.doFinal(data.getBytes("UTF-8"));
System.out.println(Base64.getEncoder().encodeToString(hmac_data));
return Base64.getEncoder().encodeToString(hmac_data);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment