Here you can find the source of hmacSha1(String data, String key)
public static String hmacSha1(String data, String key)
//package com.java2s; //License from project: Apache License import java.nio.charset.StandardCharsets; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.util.Base64; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; public class Main { public static String hmacSha1(String data, String key) { SecretKeySpec signingKey = new SecretKeySpec(key.getBytes(StandardCharsets.UTF_8), "HmacSHA1"); Mac mac = null;//w w w .j a v a 2 s . com try { mac = Mac.getInstance("HmacSHA1"); mac.init(signingKey); } catch (NoSuchAlgorithmException | InvalidKeyException e) { throw new RuntimeException(e); } byte[] rawHmac = mac.doFinal(data.getBytes(StandardCharsets.UTF_8)); return Base64.getEncoder().encodeToString(rawHmac); } }