Created
March 13, 2012 08:00
-
-
Save altmind/2027529 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TestHMAC { | |
... | |
private String calculateMAC(byte[] inputBytes, String password) throws NoSuchAlgorithmException, InvalidKeyException { | |
SecretKeySpec signingKey = new SecretKeySpec(password.getBytes(), HMAC_SHA1_ALGORITHM); | |
Mac mac = Mac.getInstance(HMAC_SHA1_ALGORITHM); | |
mac.init(signingKey); | |
byte[] rawHmac = mac.doFinal(inputBytes); | |
return new String(Hex.encodeHex(rawHmac, true)); | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment