From b635d6d867822935bc54d02fe68ccd0c4cb9c9b7 Mon Sep 17 00:00:00 2001 From: walon Date: Wed, 14 May 2025 17:26:21 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=8A=A0=E5=AF=86float?= =?UTF-8?q?=E5=92=8Cdouble=E7=9A=84=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/EncryptorBase.cs | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/Runtime/EncryptorBase.cs b/Runtime/EncryptorBase.cs index 76264e2..1f70d29 100644 --- a/Runtime/EncryptorBase.cs +++ b/Runtime/EncryptorBase.cs @@ -40,28 +40,6 @@ namespace Obfuz return ((long)decryptedHigh << 32) | (uint)decryptedLow; } - private int? _floatSalt; - - private int GetFloatSalt() - { - if (_floatSalt == null) - { - _floatSalt = Encrypt(0xABCD, 0x12345678, 0); - } - return _floatSalt.Value; - } - - private long? _doubleSalt; - - private long GetDoubleSalt() - { - if (_doubleSalt == null) - { - _doubleSalt = Encrypt(0xAABBCCDDL, 0x12345678, 0); - } - return _doubleSalt.Value; - } - public virtual float Encrypt(float value, int opts, int salt) { if (float.IsNaN(value) || float.IsInfinity(value)) @@ -69,7 +47,7 @@ namespace Obfuz return value; } ref int intValue = ref UnsafeUtility.As(ref value); - int xorValue = ((1 << 23) - 1) & (opts ^ salt ^ GetFloatSalt()); + int xorValue = ((1 << 23) - 1) & Decrypt(0xABCD, opts, salt); intValue ^= xorValue; return value; } @@ -81,7 +59,7 @@ namespace Obfuz return value; } ref int intValue = ref UnsafeUtility.As(ref value); - int xorValue = ((1 << 23) - 1) & (opts ^ salt ^ GetFloatSalt()); + int xorValue = ((1 << 23) - 1) & Decrypt(0xABCD, opts, salt); intValue ^= xorValue; return value; } @@ -93,7 +71,7 @@ namespace Obfuz return value; } ref long longValue = ref UnsafeUtility.As(ref value); - long xorValue = ((1L << 52) - 1) & ((((long)opts << 32) | (uint)salt) ^ GetDoubleSalt()); + long xorValue = ((1L << 52) - 1) & Decrypt(0xAABBCCDDL, opts, salt); longValue ^= xorValue; return value; } @@ -105,7 +83,7 @@ namespace Obfuz return value; } ref long longValue = ref UnsafeUtility.As(ref value); - long xorValue = ((1L << 52) - 1) & ((((long)opts << 32) | (uint)salt) ^ GetDoubleSalt()); + long xorValue = ((1L << 52) - 1) & Decrypt(0xAABBCCDDL, opts, salt); longValue ^= xorValue; return value; }