From fcbf77bb40283e9c0e365a9b2e1bff6a8dbdcc7d Mon Sep 17 00:00:00 2001 From: walon Date: Mon, 26 May 2025 20:03:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=9A=E5=8A=A0=E8=A7=A3?= =?UTF-8?q?=E5=AF=86=E9=95=BF=E5=BA=A6=E4=B8=BA0=E7=9A=84=E5=AD=97?= =?UTF-8?q?=E7=AC=A6=E4=B8=B2=E5=92=8Cbytes=E6=97=B6=E7=9B=B4=E6=8E=A5?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E9=95=BF=E5=BA=A6=E4=B8=BA0=E7=9A=84?= =?UTF-8?q?=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- com.code-philosophy.obfuz/Runtime/EncryptorBase.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/com.code-philosophy.obfuz/Runtime/EncryptorBase.cs b/com.code-philosophy.obfuz/Runtime/EncryptorBase.cs index 007e4b9..15416ad 100644 --- a/com.code-philosophy.obfuz/Runtime/EncryptorBase.cs +++ b/com.code-philosophy.obfuz/Runtime/EncryptorBase.cs @@ -148,6 +148,10 @@ namespace Obfuz public unsafe virtual byte[] Decrypt(byte[] value, int offset, int length, int ops, int salt) { + if (length == 0) + { + return Array.Empty(); + } var decryptedBytes = new byte[length]; int intArrLength = length >> 2; @@ -202,12 +206,20 @@ namespace Obfuz public virtual byte[] Encrypt(string value, int ops, int salt) { + if (value.Length == 0) + { + return Array.Empty(); + } byte[] bytes = Encoding.UTF8.GetBytes(value); return Encrypt(bytes, 0, bytes.Length, ops, salt); } public virtual string DecryptString(byte[] value, int offset, int length, int ops, int salt) { + if (length == 0) + { + return string.Empty; + } byte[] bytes = Decrypt(value, offset, length, ops, salt); return Encoding.UTF8.GetString(bytes); }