-
-
Save t0k4rt/ee26f3fb923fb5d56fb6 to your computer and use it in GitHub Desktop.
HMAC-SHA1 Utility for Android
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
public static String sha1(String s, String keyString) throws | |
UnsupportedEncodingException, NoSuchAlgorithmException, | |
InvalidKeyException { | |
Mac mac = Mac.getInstance("HmacSHA1"); | |
SecretKeySpec secret = new SecretKeySpec(keyString.getBytes("UTF-8"), mac.getAlgorithm()); | |
mac.init(secret); | |
byte[] digest = mac.doFinal(s.getBytes()); | |
String retVal = Base64.encodeBase64String(digest); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment