forked from aspnet/AspNetWebStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMachineKey45CryptoSystemTest.cs
More file actions
42 lines (33 loc) · 1.28 KB
/
Copy pathMachineKey45CryptoSystemTest.cs
File metadata and controls
42 lines (33 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.TestCommon;
namespace System.Web.Helpers.AntiXsrf.Test
{
public class MachineKey45CryptoSystemTest
{
[Fact]
public void Protect()
{
// Arrange
byte[] unprotectedBytes = new byte[] { 1, 2, 3, 4, 5 };
string unprotectedString = HttpServerUtility.UrlTokenEncode(unprotectedBytes);
MachineKey45CryptoSystem cryptoSystem = new MachineKey45CryptoSystem();
// Act
string protectedString = cryptoSystem.Protect(unprotectedBytes);
// Assert
Assert.NotEqual(unprotectedString, protectedString);
}
[Fact]
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);
}
}
}