private static byte[] hmac_sha(String crypto,byte[] keyBytes,byte[] text){
  try {
    Mac hmac;
    hmac=Mac.getInstance(crypto);
    SecretKeySpec macKey=new SecretKeySpec(keyBytes,"RAW");
    hmac.init(macKey);
    return hmac.doFinal(text);
  }
 catch (  GeneralSecurityException gse) {
    throw new UndeclaredThrowableException(gse);
  }
}

private static byte [ ] hmac_sha ( String crypto , byte [ ] keyBytes , byte [ ] text ) { try { Mac hmac ; hmac = Mac . getInstance ( crypto ) ; SecretKeySpec macKey = new SecretKeySpec ( keyBytes , "RAW" ) ; hmac . init ( macKey ) ; return hmac . doFinal ( text ) ; } catch ( GeneralSecurityException gse ) { throw new UndeclaredThrowableException ( gse ) ; } }
this method uses the jce to provide the crypto algorithm . hmac computes a hashed message authentication code with the crypto hash algorithm as a parameter .
