Encode() public static method

public static Encode ( byte data, MachineKeyProtection protectionOption ) : string
data byte
protectionOption MachineKeyProtection
return string
示例#1
0
        ///30Mar16 Addedd by Keyur Desai, Infosys, START

        /// <summary>
        /// Uses .NET 4.0/4.5 API.
        /// With MachineKeyProtection.Encryption option.
        /// </summary>
        /// <param name="input">String to be encrypted.</param>
        /// <returns>Encrypted string.</returns>
        internal static string Protect(string input)
        {
            byte[] bytesToProtect = System.Text.Encoding.Unicode.GetBytes(input);
#if NET40
            return(MachineKey.Encode(bytesToProtect, MachineKeyProtection.Encryption));
#else
            byte[] protectedBytes = MachineKey.Protect(bytesToProtect);
            return(Convert.ToBase64String(protectedBytes));
#endif
        }