Code example for Key

Methods: getAlgorithm

     * @param input the input over which to compute the MAC 
     * @return the computed MAC value 
     * @throws SecurityException thrown if the MAC computation results in an error 
    public static byte[] signMAC(Key signingKey, String jcaAlgorithmID, byte[] input) throws SecurityException {
        log.debug("Computing MAC over input using key of type {} and JCA algorithm ID {}", signingKey.getAlgorithm(),
        try { 
            Mac mac = Mac.getInstance(jcaAlgorithmID);
            byte[] rawMAC = mac.doFinal();
            log.debug("Computed MAC: {}", new String(Hex.encode(rawMAC)));
            return rawMAC;
        } catch (GeneralSecurityException e) {
            log.error("Error during MAC generation", e);
            throw new SecurityException("Error during MAC generation", e);