feat: wip on aes crypto provider
This commit is contained in:
@@ -0,0 +1,20 @@
|
|||||||
|
namespace StevanFreeborn.Extensions.Configuration.Secure.Cryptography;
|
||||||
|
|
||||||
|
internal sealed class AesCryptoProvider(IEncryptionKeyProvider keyProvider) : ICryptoProvider
|
||||||
|
{
|
||||||
|
private readonly IEncryptionKeyProvider _keyProvider = keyProvider
|
||||||
|
?? throw new ArgumentNullException(nameof(keyProvider));
|
||||||
|
|
||||||
|
// TODO: Implement this shit
|
||||||
|
|
||||||
|
public string Decrypt(string cipherText)
|
||||||
|
{
|
||||||
|
_ = _keyProvider.GetKey();
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Encrypt(string plainText)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
using Moq;
|
||||||
|
|
||||||
|
using StevanFreeborn.Extensions.Configuration.Secure.Cryptography;
|
||||||
|
|
||||||
|
namespace StevanFreeborn.Extensions.Configuration.Secure.Tests.Unit.Cryptography;
|
||||||
|
|
||||||
|
public class AesCryptoProviderTests
|
||||||
|
{
|
||||||
|
private readonly Mock<IEncryptionKeyProvider> _mockKeyProvider = new();
|
||||||
|
private readonly AesCryptoProvider _sut;
|
||||||
|
|
||||||
|
public AesCryptoProviderTests()
|
||||||
|
{
|
||||||
|
_sut = new(_mockKeyProvider.Object);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void EncryptAndDecrypt_WhenCalled_ItShouldReturnOriginalString()
|
||||||
|
{
|
||||||
|
var originalText = "SuperDuperSecret";
|
||||||
|
|
||||||
|
var encryptedText = _sut.Encrypt(originalText);
|
||||||
|
var decryptedText = _sut.Decrypt(encryptedText);
|
||||||
|
|
||||||
|
encryptedText.Should().NotBe(originalText);
|
||||||
|
decryptedText.Should().Be(originalText);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user