Android examples for java.security:HMAC
get Hmac Sha
//package com.java2s; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; public class Main { /**/*from w w w .j a va 2 s.c o m*/ * * @param content * @param key * @return * @throws Exception */ public static byte[] getHmacSha1(byte[] content, byte[] key) throws Exception { SecretKeySpec signingKey = new SecretKeySpec(key, "HmacSHA1"); Mac mac = Mac.getInstance(signingKey.getAlgorithm()); mac.init(signingKey); return mac.doFinal(content); } }