Java HMAC hmacSha1(byte[] secret, byte[] data)

Here you can find the source of hmacSha1(byte[] secret, byte[] data)

Description

hmac Sha

License

Apache License

Declaration

private static byte[] hmacSha1(byte[] secret, byte[] data)
            throws NoSuchAlgorithmException, InvalidKeyException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import javax.crypto.Mac;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;

public class Main {
    private static byte[] hmacSha1(byte[] secret, byte[] data)
            throws NoSuchAlgorithmException, InvalidKeyException {
        String algo = "HmacSHA1";
        SecretKey secretKey = new SecretKeySpec(secret, algo);
        Mac m = Mac.getInstance(algo);
        m.init(secretKey);/*from   www  . jav  a 2  s . c o  m*/
        return m.doFinal(data);
    }
}

Related

  1. hmacHex(String keyString, String message, String hmac)
  2. hmacSha(byte[] keyBytes, byte[] text)
  3. hmacSha(String crypto, String key, String value)
  4. hmacSha1(byte[] data, byte[] key)
  5. hmacSha1(byte[] key_bytes, byte[] text_bytes)
  6. hmacSha1(SecretKey key, byte[] data)
  7. hmacSha1(SecretKeySpec signingKey, byte[]... data)
  8. hmacSha1(String data, String key)
  9. hmacSha1(String input, byte[] keyBytes)