public void MachineKeyEncryptionTest1() { const string data = "Some text to encrypt"; var encrypted = MachineKeyEncryption.Encode(data); var decrypted = MachineKeyEncryption.Decode(encrypted); Assert.AreEqual(data, decrypted); }
public void MachineKeyEncryptionTest2() { const string originalText = "Some text to encrypt"; // ReSharper disable once CSharpWarnings::CS0618 var data = MachineKey.Encode(Encoding.UTF8.GetBytes(originalText), MachineKeyProtection.All); var decrypted = MachineKeyEncryption.Decode(data); Assert.AreEqual(originalText, decrypted); }
public string Decode(string encodedValue, bool urlDecode = false) { if (urlDecode) { encodedValue = HttpUtility.UrlDecode(encodedValue); } try { return(MachineKeyEncryption.Decode(encodedValue)); } catch (Exception) { _logManager.LogError($"Error trying to decode {encodedValue}", GetType()); return(null); } }