web.config
system.web
machineKey
validation
"SHA1"
validationKey
decryption
"AES"
decryptionKey
authentication/forms
protection
"All"
machine
private void GenerateWebConfigXml() { var newLine = Environment.NewLine + " "; var format ="<machineKey"; format += newLine; format += "validation=\"SHA1\""; format += newLine; format += "validationKey=\"{0}\""; format += newLine; format += "decryption=\"AES\""; format += newLine; format += "decryptionKey=\"{1}\""; format += newLine; format += "/>"; var dKey = GenerateRandomKey(64); var vKey = GenerateRandomKey(128); var result = string.Format(format, vKey, dKey); uxResultTextBox.Text = result; } /// <summary> /// /// </summary> /// <param name="len">KEY length (e.g., for a 32-byte key, pass 64)</param> /// <returns></returns> private string GenerateRandomKey(int len) { byte[] buff = new byte[len / 2]; var rng = new RNGCryptoServiceProvider(); rng.GetBytes(buff); var sb = new StringBuilder(len); for (int i = 0; i < buff.Length; i++) sb.Append(string.Format("{0:X2}", buff[i])); return sb.ToString(); }
ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.