Node:MAC Example, Previous:UMAC-32, Up:Message Authentication Codes



Example

     IMac mac = MacFactory.getInstance("HMAC-SHA-160");
     HashMap attributes = new HashMap();
     attributes.put(IMac.MAC_KEY_MATERIAL, key_bytes);
     attributes.put(IMac.TRUNCATED_SIZE, new Integer(12));
     mac.init(attributes);
     
     mac.update(input, 0, input.length);
     
     byte[] result = mac.digest();