Code example for Mac

Methods: doFinalinit

0
   */ 
  protected static byte[] createPassword(byte[] identifier, 
                                         SecretKey key) {
    Mac mac = threadLocalMac.get();
    try { 
      mac.init(key);
    } catch (InvalidKeyException ike) {
      throw new IllegalArgumentException("Invalid key to HMAC computation", 
                                         ike);
    } 
    return mac.doFinal(identifier);
  } 
   
  /** 
   * Convert the byte[] to a secret key 
   * @param key the byte[] to create a secret key from 
   * @return the secret key 
   */ 
  protected static SecretKey createSecretKey(byte[] key) {
    return new SecretKeySpec(key, DEFAULT_HMAC_ALGORITHM);