public class HashMac extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
ALGORITHM
The algorithm used for computing HMACs.
|
| Modifier | Constructor and Description |
|---|---|
protected |
HashMac(byte[] key,
String algorithm)
This constructor is protected so that, should you need a different algorithm (e.g.
|
|
HashMac(SecretKey key)
This constructor allows you to use a
SecretKey to generate an HMAC. |
|
HashMac(String key)
This constructor provides parity with PHP's
hash_hmac("sha256", "message", "key") function. |
| Modifier and Type | Method and Description |
|---|---|
String |
digest(String message)
Computes an HMAC for the given message, using the key passed to the constructor.
|
public static final String ALGORITHM
public HashMac(String key)
hash_hmac("sha256", "message", "key") function.key - An arbitrary String to use as a key.public HashMac(SecretKey key)
SecretKey to generate an HMAC.
NB The Key.getEncoded() method of the key should return a suitable byte array.
This is the case for keys generated/unwrapped using Cryptolite.key - An key, whose Key.getEncoded() method will be called.protected HashMac(byte[] key,
String algorithm)
key - A byte array to use as the key.algorithm - This should normally be "HmacSHA256".Copyright © 2016 Carboni. All rights reserved.