Ejemplo n.º 1
0
            public byte[] Decode(string encodedData, MachineKeyProtection protectionOption)
            {
                string optionString = protectionOption.ToString();

                if (encodedData.StartsWith(optionString, StringComparison.Ordinal))
                {
                    encodedData = encodedData.Substring(optionString.Length + 1);
                }
                else
                {
                    throw new Exception("Corrupted data.");
                }
                return(Convert.FromBase64String(encodedData));
            }
Ejemplo n.º 2
0
 public string Encode(byte[] data, MachineKeyProtection protectionOption)
 {
     return(protectionOption.ToString() + "-" + Convert.ToBase64String(data));
 }
 public string Encode(byte[] data, MachineKeyProtection protectionOption)
 {
     return protectionOption.ToString() + "-" + Convert.ToBase64String(data);
 }
 public byte[] Decode(string encodedData, MachineKeyProtection protectionOption)
 {
     string optionString = protectionOption.ToString();
     if (encodedData.StartsWith(optionString, StringComparison.Ordinal))
     {
         encodedData = encodedData.Substring(optionString.Length + 1);
     }
     else
     {
         throw new Exception("Corrupted data.");
     }
     return Convert.FromBase64String(encodedData);
 }