-
-
Save roadlabs/2ed7c2157cfb3dad794d59cfaeef42db to your computer and use it in GitHub Desktop.
HMAC-SHA1 Utility for Android
This file contains hidden or 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 { | |
SecretKeySpec key = new SecretKeySpec((keyString).getBytes("UTF-8"), "HmacSHA1"); | |
Mac mac = Mac.getInstance("HmacSHA1"); | |
mac.init(key); | |
byte[] bytes = mac.doFinal(s.getBytes("UTF-8")); | |
return new String( Base64.encodeBase64(bytes) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment