/// <summary> /// Renders a hidden form field that contains a value encrypted with AES. The key for the encryption must /// be set in your web.config with the <see cref="CryptoConfigurationSection"/>. /// </summary> /// <param name="html">The <see cref="HtmlHelper"/></param> /// <param name="name">The name of the field</param> /// <param name="value">The value to encrypt</param> /// <param name="htmlAttributes">An object containing the HTML attributes for the element.</param> /// <returns>The HTML</returns> public static MvcHtmlString EncryptedHidden(this HtmlHelper html, string name, string value, IDictionary <string, object> htmlAttributes) { string encryptedValue; using (ICrypto crypto = new AesCrypto()) { encryptedValue = crypto.EncryptToBase64(value); } return(html.Hidden(name, encryptedValue, htmlAttributes)); }