Decode() public static method

public static Decode ( string encodedData, MachineKeyProtection protectionOption ) : byte[]
encodedData string
protectionOption MachineKeyProtection
return byte[]
Example #1
0
        /// <summary>
        /// Uses .NET 4.0/4.5 API.
        /// With MachineKeyProtection.Encryption option.
        /// </summary>
        /// <param name="input">String to be decrypted.</param>
        /// <returns>Decrypted string.</returns>
        internal static string Unprotect(string input)
        {
#if NET40
            byte[] unprotectedBytes = MachineKey.Decode(input, MachineKeyProtection.Encryption);
            return(System.Text.Encoding.Unicode.GetString(unprotectedBytes));
#else
            byte[] protectedBytes   = Convert.FromBase64String(input);
            byte[] unprotectedBytes = MachineKey.Unprotect(protectedBytes);
            return(System.Text.Encoding.Unicode.GetString(unprotectedBytes));
#endif
        }