diff --git a/src/StevanFreeborn.Extensions.Configuration.Secure/Cryptography/StaticKeyProvider.cs b/src/StevanFreeborn.Extensions.Configuration.Secure/Cryptography/StaticKeyProvider.cs index 799caf3..cf2c8a0 100644 --- a/src/StevanFreeborn.Extensions.Configuration.Secure/Cryptography/StaticKeyProvider.cs +++ b/src/StevanFreeborn.Extensions.Configuration.Secure/Cryptography/StaticKeyProvider.cs @@ -8,7 +8,7 @@ internal sealed class StaticKeyProvider : IEncryptionKeyProvider { if (string.IsNullOrWhiteSpace(base64Key)) { - throw new ArgumentNullException(nameof(base64Key)); + throw new ArgumentException("Cannot be null or whitespace.", nameof(base64Key)); } byte[] decodedKey; @@ -22,7 +22,7 @@ internal sealed class StaticKeyProvider : IEncryptionKeyProvider throw new ArgumentException("The provided key is not a valid Base64 string.", nameof(base64Key), ex); } - if (decodedKey.Length != 32) + if (decodedKey.Length is not 32) { throw new ArgumentException("The encryption key must be exactly 32 bytes (256 bits) for AES-256 encryption.", nameof(base64Key)); } diff --git a/tests/StevanFreeborn.Extensions.Configuration.Secure.Tests/Unit/Cryptography/StaticKeyProviderTests.cs b/tests/StevanFreeborn.Extensions.Configuration.Secure.Tests/Unit/Cryptography/StaticKeyProviderTests.cs index 08cfeee..a9cf60c 100644 --- a/tests/StevanFreeborn.Extensions.Configuration.Secure.Tests/Unit/Cryptography/StaticKeyProviderTests.cs +++ b/tests/StevanFreeborn.Extensions.Configuration.Secure.Tests/Unit/Cryptography/StaticKeyProviderTests.cs @@ -9,7 +9,7 @@ public class StaticKeyProviderTests { var act = () => new StaticKeyProvider(null!); - act.Should().Throw(); + act.Should().Throw(); } [Fact]