public static byte[] ComputeDerivedKey(KeyedHashAlgorithm hmacAlgorithm, byte[] salt, int iterations, int derivedKeyLength) { NBitcoin.Crypto.Internal.Check.Range("derivedKeyLength", derivedKeyLength, 0, int.MaxValue); using (Pbkdf2 kdf = new Pbkdf2(hmacAlgorithm, salt, iterations)) { return(kdf.Read(derivedKeyLength)); } }
/// <summary> /// Computes a derived key. /// </summary> /// <param name="hmacAlgorithm"> /// </param> /// <param name="salt"> /// The salt. /// A unique salt means a unique derived key, even if the original key is identical. /// </param> /// <param name="iterations">The number of iterations to apply.</param> /// <param name="derivedKeyLength">The desired length of the derived key.</param> /// <returns>The derived key.</returns> #if NETCORE public static byte[] ComputeDerivedKey(IMac hmacAlgorithm, byte[] salt, int iterations, int derivedKeyLength) { Check.Range("derivedKeyLength", derivedKeyLength, 0, int.MaxValue); using (var kdf = new Pbkdf2(hmacAlgorithm, salt, iterations)) { return(kdf.Read(derivedKeyLength)); } }