示例#1
0
 private static byte[] Pbkdf2(string password, byte[] salt, int iterations, int outputBytes)
 {
     using (var provider = new Pbkdf2Provider(password, salt, iterations))
         return(provider.GetDerivedKeyBytes(outputBytes));
 }
示例#2
0
 /// <summary>
 ///     A publicly exposed version of GetDerivedKeyBytes_PBKDF2_HMAC which matches the exact specification in Rfc2898
 ///     PBKDF2 using HMAC
 /// </summary>
 /// <param name="password">Password passed as a Byte Array</param>
 /// <param name="salt">Salt passed as a Byte Array</param>
 /// <param name="iterations">Iterations to perform the underlying PRF over</param>
 /// <param name="keyLength">Length of Bytes to return, an AES 256 key word require 32 Bytes</param>
 /// <returns>Derived Key in Byte Array form ready for use by chosen encryption function</returns>
 public byte[] Pbkdf2(byte[] password, byte[] salt, int iterations, int keyLength)
 {
     using (var provider = new Pbkdf2Provider(password, salt, iterations))
         return(provider.GetDerivedKeyBytes(keyLength));
 }