Class 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 key
        text - the message or text to be authenticated
        Returns:
        hash byte array
        Throws:
        java.security.NoSuchAlgorithmException - if hmac sha1 is not available
        java.security.InvalidKeyException - if given key is inappropriate for this mac