Created
September 8, 2011 08:57
-
-
Save tistaharahap/1202974 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 { | |
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) ); | |
} |
replace the line for...
return new String(Base64.encodeToString(bytes, 0));
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Base64.encodeBase64 does not existss in android.