Package io.micronaut.security.utils
Class HMacUtils
java.lang.Object
io.micronaut.security.utils.HMacUtils
Utility methods for HMAC.
- Since:
- 4.11.0
- Author:
- Sergio del Amo
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
base64EncodedHmac
(@NonNull String algorithm, @NonNull String data, @NonNull String key) static String
base64EncodedHmacSha256
(@NonNull String data, @NonNull String key)
-
Method Details
-
base64EncodedHmacSha256
public static String base64EncodedHmacSha256(@NonNull @NonNull String data, @NonNull @NonNull String key) throws NoSuchAlgorithmException, InvalidKeyException - Parameters:
data
- Datakey
- Signature Key- Returns:
- HMAC SHA-256 encoded in Base64
- Throws:
NoSuchAlgorithmException
- if noProvider
supports aMacSpi
implementation for the specified algorithm.InvalidKeyException
- if the given key is inappropriate for initializing this MAC.
-
base64EncodedHmac
public static String base64EncodedHmac(@NonNull @NonNull String algorithm, @NonNull @NonNull String data, @NonNull @NonNull String key) throws NoSuchAlgorithmException, InvalidKeyException - Parameters:
algorithm
- HMAC algorithmdata
- Datakey
- Signature Key- Returns:
- HMAC encoded in Base64
- Throws:
NoSuchAlgorithmException
- if noProvider
supports aMacSpi
implementation for the specified algorithm.InvalidKeyException
- if the given key is inappropriate for initializing this MAC.
-