Java tutorial
//package com.java2s; //License from project: Apache License import java.io.UnsupportedEncodingException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; public class Main { public static byte[] hmacSha1(String key, String value) throws UnsupportedEncodingException, NoSuchAlgorithmException, InvalidKeyException { String type = "HmacSHA1"; SecretKeySpec secret = new SecretKeySpec(key.getBytes(), type); Mac mac = Mac.getInstance(type); mac.init(secret); return mac.doFinal(value.getBytes()); } }