/** * Calculate the hash-based message authentication code. * * @param key the key * @param message the message * @return the hash */ public static byte[] getHMAC(byte[] key, byte[] message) { key = normalizeKeyForHMAC(key); int len = message.length; int byteLen = 64 + Math.max(32, len); int intLen = getIntCount(byteLen); byte[] byteBuff = new byte[intLen * 4]; int[] intBuff = new int[intLen]; SHA256 sha = new SHA256(); byte[] iKey = new byte[64 + len]; byte[] oKey = new byte[64 + 32]; sha.calculateHMAC(key, message, len, iKey, oKey, byteBuff, intBuff); return sha.result; }
byte[] key = normalizeKeyForHMAC(password); SHA256 sha = new SHA256(); int len = 64 + Math.max(32, salt.length + 4);