Machinekey Generation Code:
Code
validationKey = CreateKey(20);
decryptionKey = CreateKey(24);
protected string CreateKey(int len)
{
byte[] bytes = new byte[len];
new RNGCryptoServiceProvider().GetBytes(bytes);
StringBuilder sb = new StringBuilder();
for(int i = 0; i < bytes.Length; i++)
{
sb.Append(string.Format("{0:X2}",bytes[i]));
}
return sb.ToString();
}
Web. config Configuration:
Code
xml version="1.0"?>
<configuration>
<system.web>
<machineKey validationKey="3FF1E929BC0534950B0920A7B59FA698BD02DFE8" decryptionKey="280450BB36319B474C996B506A95AEDF9B51211B1D2B7A77" decryption="3DES" validation="SHA1"/>
system.web>
configuration>
Machinekey:
1) encryption and decryption during Forms authentication tickets authentication to prevent tampering.
2) viewstate encryption and decryption to prevent tampering.
3) when an out-of-process session is used, the session Status identifier is verified.