Here you can find the source of hmacSha1(String input, byte[] keyBytes)
public static byte[] hmacSha1(String input, byte[] keyBytes)
//package com.java2s; /**// w ww . j a v a2 s . c om * Copyright (c) 2005-2010 wwinsoft.org.cn * * Licensed under the Apache License, Version 2.0 (the "License"); * * $Id: CryptoUtils.java 764 2009-12-27 19:13:59Z calvinxiu $ */ import java.security.GeneralSecurityException; import javax.crypto.Mac; import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; public class Main { private static final String HMACSHA1 = "HmacSHA1"; public static byte[] hmacSha1(String input, byte[] keyBytes) { try { SecretKey secretKey = new SecretKeySpec(keyBytes, HMACSHA1); Mac mac = Mac.getInstance(HMACSHA1); mac.init(secretKey); return mac.doFinal(input.getBytes()); } catch (GeneralSecurityException e) { throw convertRuntimeException(e); } } private static IllegalStateException convertRuntimeException(GeneralSecurityException e) { return new IllegalStateException("Security exception", e); } }