コード例 #1
0
ファイル: MachineKeyEncryption.cs プロジェクト: eugeb/Custom2
 /// <summary>
 /// Decrypts the given string using the <see cref="System.Web.Security.MachineKey"/> class
 /// </summary>
 /// <param name="encryptedString">The encrypted string</param>
 /// <param name="additionalPurposes">Any additional encryption Purposes you want to add to the default MachineKey Purpose. The list of purposes has to be in the same order as they where when Encrypt was called</param>
 /// <returns>The string to decrypt</returns>
 public static string Decrypt(string encryptedString, params string[] additionalPurposes)
 {
     try
     {
         string encryptedTicket = MachineKeyEncryption.Decompress(MachineKeyEncryption.Unprotect(encryptedString, additionalPurposes));
         return(encryptedTicket);
     }
     catch (CryptographicException)
     {
         return(string.Empty);
     }
 }
コード例 #2
0
ファイル: MachineKeyEncryption.cs プロジェクト: eugeb/Custom2
        /// <summary>
        /// Encrypts the given string using the <see cref="System.Web.Security.MachineKey"/> class
        /// </summary>
        /// <param name="stringToEncrypt">The string to encrypt</param>
        /// <param name="additionalPurposes">Any additional encryption Purposes you want to add to the default MachineKey Purpose.</param>
        /// <returns>The encrypted string</returns>
        public static string Encrypt(string stringToEncrypt, params string[] additionalPurposes)
        {
            string securityString = MachineKeyEncryption.Protect(MachineKeyEncryption.Compress(stringToEncrypt), additionalPurposes);

            return(securityString);
        }