I am trying to generate a key using the .net 2.0 PasswordDeriveBytes class.
PasswordDeriveBytes pdb = new PasswordDeriveBytes('blahblahblah',null); byte[] iv = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }; byte[] key = pdb.CryptDeriveKey('TripleDES', 'SHA1', 128, iv);
The code throws ‘CryptographicException: Invalid flags specified.’ when trying to execute the CryptDeriveKey method above. I’m trying to encrypt a database entry in asp.net and this is my first shot a crypto. I’d appreciate any help.
According to MSDN:
‘If the keySize parameter is set to 0 bits, the default key size for the specified algorithm is used.’
MSDN PasswordDeriveBytes.CryptDeriveKey Method
Unless you have a good reason for specifying the size I’d suggest just leaving it 0.