public void Unprotect() { // Arrange byte[] unprotectedBytes = new byte[] { 1, 2, 3, 4, 5 }; MachineKey45CryptoSystem cryptoSystem = new MachineKey45CryptoSystem(); // Act string protectedString = cryptoSystem.Protect(unprotectedBytes); byte[] output = cryptoSystem.Unprotect(protectedString); // Assert Assert.Equal(unprotectedBytes, output); }
public void Unprotect() { // Arrange byte[] unprotectedBytes = new byte[] { 1, 2, 3, 4, 5 }; MachineKey45CryptoSystem cryptoSystem = new MachineKey45CryptoSystem(); // Act string protectedString = cryptoSystem.Protect(unprotectedBytes); byte[] output = cryptoSystem.Unprotect(protectedString); // Assert Assert.Equal(unprotectedBytes, output); }
public void Unprotect() { // Arrange byte[] expectedInputBytes = new byte[] { 1, 2, 3, 4, 5 }; string expectedInputString = HttpServerUtility.UrlTokenEncode(expectedInputBytes); byte[] expectedOutputBytes = new byte[] { 6, 7, 8, 9, 10 }; Func<byte[], string[], byte[]> unprotectThunk = (input, purposes) => { Assert.Equal(expectedInputBytes, input); Assert.Equal(new string[] { "System.Web.Helpers.AntiXsrf.AntiForgeryToken.v1" }, purposes); return expectedOutputBytes; }; MachineKey45CryptoSystem cryptoSystem = new MachineKey45CryptoSystem(null, unprotectThunk); // Act byte[] output = cryptoSystem.Unprotect(expectedInputString); // Assert Assert.Equal(expectedOutputBytes, output); }
public void Unprotect() { // Arrange byte[] expectedInputBytes = new byte[] { 1, 2, 3, 4, 5 }; string expectedInputString = HttpServerUtility.UrlTokenEncode(expectedInputBytes); byte[] expectedOutputBytes = new byte[] { 6, 7, 8, 9, 10 }; Func <byte[], string[], byte[]> unprotectThunk = (input, purposes) => { Assert.Equal(expectedInputBytes, input); Assert.Equal(new string[] { "System.Web.Helpers.AntiXsrf.AntiForgeryToken.v1" }, purposes); return(expectedOutputBytes); }; MachineKey45CryptoSystem cryptoSystem = new MachineKey45CryptoSystem(null, unprotectThunk); // Act byte[] output = cryptoSystem.Unprotect(expectedInputString); // Assert Assert.Equal(expectedOutputBytes, output); }