Rfc2898DeriveBytes.Salt Property
Assembly: mscorlib (in mscorlib.dll)
Salt, a random set of bytes, is used to make unauthorized decrypting of a message more difficult. A dictionary attack is an attack in which the attacker attempts to decrypt an encrypted message by comparing the encrypted value with previously computed encrypted values for the most likely keys. This attack is made much more difficult by the introduction of salt, or random bytes, at the end of the password before the key derivation.
The following code example uses the Rfc2898DeriveBytes class to create two identical keys for the TripleDES class. It then encrypts and decrypts some data using the keys.
string pwd1 = passwordargs[0]; byte[] salt1 = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0xF1, 0xF0, 0xEE, 0x21, 0x22, 0x45}; //data1 can be a string or contents of a file. string data1 = "Some test data"; //The default iteration count is 1000 so the two methods use the same iteration count. int myIterations = 1000;
String pwd1 = (String)passwordArgs.get_Item(0);
ubyte salt1[] = new ubyte[] { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6,
0xF1, 0xF0, 0xEE, 0x21, 0x22, 0x45 };
//data1 can be a string or contents of a file.
String data1 = "Some test data";
//The default iteration count is 1000 so the two methods use the
//same iteration count.
int myIterations = 1000;
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.