IdentityShroud/IdentityShroud.Core.Tests/Services/EncryptionServiceTests.cs

22 lines
559 B
C#
Raw Permalink Normal View History

using System.Security.Cryptography;
using IdentityShroud.Core.Services;
namespace IdentityShroud.Core.Tests.Services;
public class EncryptionServiceTests
{
[Fact]
public void RoundtripWorks()
{
// setup
string key = Convert.ToBase64String(RandomNumberGenerator.GetBytes(32));
EncryptionService sut = new(key);
byte[] input = RandomNumberGenerator.GetBytes(16);
// act
var cipher = sut.Encrypt(input);
var result = sut.Decrypt(cipher);
Assert.Equal(input, result);
}
}