Skip to content

Instantly share code, notes, and snippets.

@blaskey
Created March 13, 2014 17:53
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 blaskey/9533364 to your computer and use it in GitHub Desktop.
Save blaskey/9533364 to your computer and use it in GitHub Desktop.
Mac sha256HMAC = javax.crypto.Mac.getInstance("HmacSHA256");
SecretKeySpec secretKey = new SecretKeySpec(teamAPIKEY.getBytes(), "HmacSHA256");
sha256HMAC.init(secretKey);
String encodedHMAC256 = Base64.encodeBase64String(sha256HMAC.doFinal(jsonBody.getBytes("UTF-8")));
@justqyx
Copy link

justqyx commented Apr 24, 2017

Add a ruby demo

digest = OpenSSL::Digest.new('sha256')
secure_key = ''
data = ''
encoded_hmac = Base64.encode64(OpenSSL::HMAC.digest(digest, secret_key, data)).strip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment