Package com.amdelamar.jotp.util
Class Utils
- java.lang.Object
-
- com.amdelamar.jotp.util.Utils
-
public final class Utils extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]
hmac(java.lang.String alg, byte[] keyBytes, byte[] text)
Uses the JCE to provide the cryptographic hash.
-
-
-
Method Detail
-
hmac
public static byte[] hmac(java.lang.String alg, byte[] keyBytes, byte[] text) throws java.security.NoSuchAlgorithmException, java.security.InvalidKeyException
Uses the JCE to provide the cryptographic hash. HMAC computes a Hashed Message Authentication Code with the hash algorithm as a parameter.- Parameters:
alg
- algorithm (HmacSHA1, HmacSHA256, HmacSHA512)keyBytes
- the bytes to use for the HMAC keytext
- the message or text to be authenticated- Returns:
- hash byte array
- Throws:
java.security.NoSuchAlgorithmException
- if hmac sha1 is not availablejava.security.InvalidKeyException
- if given key is inappropriate for this mac
-
-