Reputation: 3
Rfc2898DeriveBytes k1 = new Rfc2898DeriveBytes(pwd1, salt1, myIterations);
Rfc2898DeriveBytes k2 = new Rfc2898DeriveBytes(pwd1, salt1);
// Encrypt the data.
TripleDES encAlg = TripleDES.Create();
encAlg.Key = k1.GetBytes(16);
My question is why is .GetByte 16? Also is it the same for RijndaelManaged? it requires 16 bytes?
Upvotes: 0
Views: 377
Reputation: 10401
It is because of the size of the key needed to the algorithm:
Of course, nothing stops you from generating more bytes from key derivator, but these algorithms will either trim the unneeded data or just plain fail to work if the size is not legal - http://msdn.microsoft.com/en-us/library/system.security.cryptography.symmetricalgorithm.legalkeysizes(v=vs.110).aspx.
Upvotes: 1