diff --git a/src/Pandatech.Crypto/Aes256.cs b/src/Pandatech.Crypto/Aes256.cs
index 6b40420..576b108 100644
--- a/src/Pandatech.Crypto/Aes256.cs
+++ b/src/Pandatech.Crypto/Aes256.cs
@@ -61,7 +61,8 @@ private byte[] EncryptWithHashInner(string plainText, string? key = null)
private byte[] EncryptWithoutHashInner(string plainText, string? key)
{
key ??= _options.Key;
- ValidateText(plainText);
+ if (plainText == "")
+ return [];
using var aesAlg = Aes.Create();
aesAlg.KeySize = KeySize;
aesAlg.Padding = PaddingMode.PKCS7;
@@ -111,7 +112,7 @@ public string DecryptWithoutHash(byte[] cipherText, string key)
? ""
: DecryptWithoutSkippingHashInner(cipherText, key);
}
-
+
public void Decrypt(Stream inputStream, Stream outputStream, string? key = null)
{
key ??= _options.Key;
@@ -135,7 +136,8 @@ public void Decrypt(Stream inputStream, Stream outputStream, string? key = null)
private string DecryptWithoutSkippingHashInner(byte[] cipherText, string? key)
{
key ??= _options.Key;
- ValidateCipherText(cipherText);
+ if (cipherText.Length == 0)
+ return "";
var iv = cipherText.Take(IvSize).ToArray();
var encrypted = cipherText.Skip(IvSize).ToArray();
@@ -166,19 +168,6 @@ private static void ValidateKey(string key)
throw new ArgumentException("Invalid key.");
}
- private static void ValidateText(string text)
- {
- if (string.IsNullOrEmpty(text) && text != null)
- throw new ArgumentException("Text cannot be null or empty.");
- }
-
- private static void ValidateCipherText(byte[] cipherText)
- {
- if (cipherText.Length == 0) return;
-
- if (cipherText == null || cipherText.Length < IvSize)
- throw new ArgumentException("Invalid cipher text.");
- }
private static bool IsBase64String(string s)
{
diff --git a/src/Pandatech.Crypto/Pandatech.Crypto.csproj b/src/Pandatech.Crypto/Pandatech.Crypto.csproj
index fdfcbf7..90a61e3 100644
--- a/src/Pandatech.Crypto/Pandatech.Crypto.csproj
+++ b/src/Pandatech.Crypto/Pandatech.Crypto.csproj
@@ -8,12 +8,12 @@