fix: use proper exception type
This commit is contained in:
+2
-2
@@ -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));
|
||||
}
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ public class StaticKeyProviderTests
|
||||
{
|
||||
var act = () => new StaticKeyProvider(null!);
|
||||
|
||||
act.Should().Throw<ArgumentNullException>();
|
||||
act.Should().Throw<ArgumentException>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
Reference in New Issue
Block a user