Пример #1
0
        /// <summary>
        /// Mimics constructor of regular Vector3.
        /// </summary>
        /// <param name="x">X component of the vector</param>
        /// <param name="y">Y component of the vector</param>
        /// <param name="z">Z component of the vector</param>
        public ObscuredVector3(float x, float y, float z)
        {
            currentCryptoKey = cryptoKey;
            hiddenValue      = Encrypt(x, y, z, currentCryptoKey);

            inited = true;
        }
Пример #2
0
        /// <summary>
        /// Allows to change current crypto key to the new random value and re-encrypt variable using it.
        /// Use it for extra protection against 'unknown value' search.
        /// Just call it sometimes when your variable doesn't change to fool the cheater.
        /// </summary>
        public void RandomizeCryptoKey()
        {
            Vector3 decrypted = InternalDecrypt();

            currentCryptoKey = Random.seed;
            hiddenValue      = Encrypt(decrypted, currentCryptoKey);
        }
Пример #3
0
        /// <summary>
        /// Allows to change current crypto key to the new random value and re-encrypt variable using it.
        /// Use it for extra protection against 'unknown value' search.
        /// Just call it sometimes when your variable doesn't change to fool the cheater.
        /// </summary>
        public void RandomizeCryptoKey()
        {
            Vector3 decrypted = InternalDecrypt();

            currentCryptoKey = Random.Range(int.MinValue, int.MaxValue);
            hiddenValue      = Encrypt(decrypted, currentCryptoKey);
        }
Пример #4
0
        private ObscuredVector3(Vector3 value)
        {
            currentCryptoKey = cryptoKey;
            hiddenValue      = Encrypt(value);

            inited = true;
        }
        private Vector3 InternalDecrypt()
        {
            if (!inited)
            {
                currentCryptoKey = cryptoKey;
                hiddenValue      = Encrypt(initialFakeValue, cryptoKey);
                inited           = true;
            }

            int key = cryptoKey;

            if (currentCryptoKey != cryptoKey)
            {
                key = currentCryptoKey;
            }

            Vector3 value;

            value.x = ObscuredFloat.Decrypt(hiddenValue.x, key);
            value.y = ObscuredFloat.Decrypt(hiddenValue.y, key);
            value.z = ObscuredFloat.Decrypt(hiddenValue.z, key);


            return(value);
        }
Пример #6
0
        /// <summary>
        /// Creates and fills obscured variable with raw encrypted value previously got from GetEncrypted().
        /// </summary>
        /// Literally does same job as SetEncrypted() but makes new instance instead of filling existing one,
        /// making it easier to initialize new variables from saved encrypted values.
        ///
        /// Make sure this obscured type currently has same crypto key as when encrypted value was got with GetEncrypted().
        /// It will be same (default) if you did not used SetNewCryptoKey().
        /// <param name="encrypted">Raw encrypted value you got from GetEncrypted().</param>
        /// <returns>New obscured variable initialized from specified encrypted value.</returns>
        /// \sa GetEncrypted(), SetEncrypted()
        public static ObscuredVector3 FromEncrypted(RawEncryptedVector3 encrypted)
        {
            var instance = new ObscuredVector3();

            instance.SetEncrypted(encrypted);
            return(instance);
        }
Пример #7
0
		private ObscuredVector3(RawEncryptedVector3 encrypted)
		{
			currentCryptoKey = cryptoKey;
			hiddenValue = encrypted;
			fakeValue = initialFakeValue;
			inited = true;
		}
Пример #8
0
        /// <summary>
        /// Allows to change current crypto key to the new random value and re-encrypt variable using it.
        /// Use it for extra protection against 'unknown value' search.
        /// Just call it sometimes when your variable doesn't change to fool the cheater.
        /// </summary>
        public void RandomizeCryptoKey()
        {
            var decrypted = InternalDecrypt();

            currentCryptoKey = ThreadSafeRandom.Next();
            hiddenValue      = Encrypt(decrypted, currentCryptoKey);
        }
Пример #9
0
        public void RandomizeCryptoKey()
        {
            var decrypted = InternalDecrypt();

            currentCryptoKey = GenerateKey();
            hiddenValue      = Encrypt(decrypted, currentCryptoKey);
        }
Пример #10
0
        private Vector3 InternalDecrypt()
        {
            if (!inited)
            {
                currentCryptoKey = cryptoKey;
                hiddenValue      = Encrypt(zero, cryptoKey);
                fakeValue        = zero;
                fakeValueActive  = false;
                inited           = true;

                return(zero);
            }

            Vector3 value;

            value.x = ObscuredFloat.Decrypt(hiddenValue.x, currentCryptoKey);
            value.y = ObscuredFloat.Decrypt(hiddenValue.y, currentCryptoKey);
            value.z = ObscuredFloat.Decrypt(hiddenValue.z, currentCryptoKey);

            if (Detectors.ObscuredCheatingDetector.IsRunning && fakeValueActive && !CompareVectorsWithTolerance(value, fakeValue))
            {
                Detectors.ObscuredCheatingDetector.Instance.OnCheatingDetected();
            }

            return(value);
        }
Пример #11
0
 private ObscuredVector3(RawEncryptedVector3 encrypted)
 {
     currentCryptoKey = cryptoKey;
     hiddenValue      = encrypted;
     fakeValue        = initialFakeValue;
     inited           = true;
 }
Пример #12
0
        private Vector3 InternalDecrypt()
        {
            if (!inited)
            {
                currentCryptoKey = cryptoKey;
                hiddenValue      = Encrypt(initialFakeValue, cryptoKey);
                fakeValue        = initialFakeValue;
                inited           = true;
            }

            int key = cryptoKey;

            if (currentCryptoKey != cryptoKey)
            {
                key = currentCryptoKey;
            }

            Vector3 value;

            value.x = ObscuredFloat.Decrypt(hiddenValue.x, key);
            value.y = ObscuredFloat.Decrypt(hiddenValue.y, key);
            value.z = ObscuredFloat.Decrypt(hiddenValue.z, key);

            if (Detectors.ObscuredCheatingDetector.isRunning && !fakeValue.Equals(Vector3.zero) && !CompareVectorsWithTolerance(value, fakeValue))
            {
                Detectors.ObscuredCheatingDetector.Instance.OnCheatingDetected();
            }

            return(value);
        }
Пример #13
0
 public void SetEncryptedDeprecated(Vector3 encrypted)
 {
     hiddenValue = (RawEncryptedVector3)encrypted;
     if (Detectors.ObscuredCheatingDetector.isRunning)
     {
         fakeValue = InternalDecrypt();
     }
 }
Пример #14
0
 /// <summary>
 /// Use it after SetNewCryptoKey() to re-encrypt current instance using new crypto key.
 /// </summary>
 public void ApplyNewCryptoKey()
 {
     if (currentCryptoKey != cryptoKey)
     {
         hiddenValue      = Encrypt(InternalDecrypt(), cryptoKey);
         currentCryptoKey = cryptoKey;
     }
 }
Пример #15
0
 /// <summary>
 /// Allows to explicitly set current obscured value.
 /// </summary>
 /// Use it in conjunction with GetEncrypted().<br/>
 /// Useful for loading data stored in obscured state.
 public void SetEncrypted(RawEncryptedVector3 encrypted)
 {
     inited      = true;
     hiddenValue = encrypted;
     if (Detectors.ObscuredCheatingDetector.IsRunning)
     {
         fakeValue = InternalDecrypt();
     }
 }
Пример #16
0
        /// <summary>
        /// Decrypts passed value you got from Encrypt() using same key.
        /// </summary>
        /// \sa Encrypt()
        public static Vector3 Decrypt(RawEncryptedVector3 value, int key)
        {
            Vector3 result;

            result.x = ObscuredFloat.Decrypt(value.x, key);
            result.y = ObscuredFloat.Decrypt(value.y, key);
            result.z = ObscuredFloat.Decrypt(value.z, key);

            return(result);
        }
Пример #17
0
        /// <summary>
        /// Allows to change current crypto key to the new random value and re-encrypt variable using it.
        /// Use it for extra protection against 'unknown value' search.
        /// Just call it sometimes when your variable doesn't change to fool the cheater.
        /// </summary>
        public void RandomizeCryptoKey()
        {
            var decrypted = InternalDecrypt();

            do
            {
                currentCryptoKey = Random.Range(int.MinValue, int.MaxValue);
            } while (currentCryptoKey == 0);
            hiddenValue = Encrypt(decrypted, currentCryptoKey);
        }
Пример #18
0
        /// <summary>
        /// Allows to explicitly set current obscured value.
        /// </summary>
        /// Use it in conjunction with GetEncrypted().<br/>
        /// Useful for loading data stored in obscured state.
        public void SetEncrypted(RawEncryptedVector3 encrypted)
        {
            inited      = true;
            hiddenValue = encrypted;

            if (currentCryptoKey == 0)
            {
                currentCryptoKey = cryptoKey;
            }
        }
Пример #19
0
        private ObscuredVector3(Vector3 value)
        {
            currentCryptoKey = cryptoKey;
            hiddenValue      = Encrypt(value);

            bool detectorRunning = Detectors.ObscuredCheatingDetector.IsRunning;

            fakeValue       = detectorRunning ? value : zero;
            fakeValueActive = detectorRunning;

            inited = true;
        }
Пример #20
0
        private ObscuredVector3(Vector3 value)
        {
            currentCryptoKey = GenerateKey();
            hiddenValue      = Encrypt(value, currentCryptoKey);

#if UNITY_EDITOR
            fakeValue       = value;
            fakeValueActive = true;
            migratedVersion = null;
#else
            var detectorRunning = Detectors.ObscuredCheatingDetector.ExistsAndIsRunning;
            fakeValue       = detectorRunning ? value : Zero;
            fakeValueActive = detectorRunning;
#endif
            inited = true;
        }
Пример #21
0
        /// <summary>
        /// Allows to explicitly set current obscured value. Crypto key should be same as when encrypted value was got with GetEncrypted().
        /// </summary>
        /// Use it in conjunction with GetEncrypted().<br/>
        /// Useful for loading data stored in obscured state.
        /// \sa FromEncrypted()
        public void SetEncrypted(RawEncryptedVector3 encrypted, int key)
        {
            inited           = true;
            hiddenValue      = encrypted;
            currentCryptoKey = key;

            if (Detectors.ObscuredCheatingDetector.ExistsAndIsRunning)
            {
                fakeValueActive = false;
                fakeValue       = InternalDecrypt();
                fakeValueActive = true;
            }
            else
            {
                fakeValueActive = false;
            }
        }
Пример #22
0
        private Vector3 InternalDecrypt()
        {
            if (!inited)
            {
                currentCryptoKey = cryptoKey;
                hiddenValue      = Encrypt(zero, cryptoKey);
                inited           = true;

                return(zero);
            }

            Vector3 value;

            value.x = ObscuredFloat.Decrypt(hiddenValue.x, currentCryptoKey);
            value.y = ObscuredFloat.Decrypt(hiddenValue.y, currentCryptoKey);
            value.z = ObscuredFloat.Decrypt(hiddenValue.z, currentCryptoKey);

            return(value);
        }
Пример #23
0
        /// <summary>
        /// Mimics constructor of regular Vector3.
        /// </summary>
        /// <param name="x">X component of the vector</param>
        /// <param name="y">Y component of the vector</param>
        /// <param name="z">Z component of the vector</param>
        public ObscuredVector3(float x, float y, float z)
        {
            currentCryptoKey = cryptoKey;
            hiddenValue      = Encrypt(x, y, z, currentCryptoKey);

            if (Detectors.ObscuredCheatingDetector.IsRunning)
            {
                fakeValue.x     = x;
                fakeValue.y     = y;
                fakeValue.z     = z;
                fakeValueActive = true;
            }
            else
            {
                fakeValue       = zero;
                fakeValueActive = false;
            }

            inited = true;
        }
Пример #24
0
        /// <summary>
        /// Mimics constructor of regular Vector3.
        /// </summary>
        /// <param name="x">X component of the vector</param>
        /// <param name="y">Y component of the vector</param>
        /// <param name="z">Z component of the vector</param>
        public ObscuredVector3(float x, float y, float z)
        {
            currentCryptoKey = GenerateKey();
            hiddenValue      = Encrypt(x, y, z, currentCryptoKey);

            if (Detectors.ObscuredCheatingDetector.ExistsAndIsRunning)
            {
                fakeValue       = new Vector3(x, y, z);
                fakeValueActive = true;
            }
            else
            {
                fakeValue       = Zero;
                fakeValueActive = false;
            }

#if UNITY_EDITOR
            migratedVersion = null;
#endif
            inited = true;
        }
Пример #25
0
        private Vector3 InternalDecrypt()
        {
            if (!inited)
            {
                currentCryptoKey = GenerateKey();
                hiddenValue      = Encrypt(Zero, currentCryptoKey);
                fakeValue        = Zero;
                fakeValueActive  = false;
                inited           = true;

                return(Zero);
            }

            var decrypted = Decrypt(hiddenValue, currentCryptoKey);

            if (Detectors.ObscuredCheatingDetector.ExistsAndIsRunning && fakeValueActive && !CompareVectorsWithTolerance(decrypted, fakeValue))
            {
                Detectors.ObscuredCheatingDetector.Instance.OnCheatingDetected();
            }

            return(decrypted);
        }
Пример #26
0
		/// <summary>
		/// Use it after SetNewCryptoKey() to re-encrypt current instance using new crypto key.
		/// </summary>
		public void ApplyNewCryptoKey()
		{
			if (currentCryptoKey != cryptoKey)
			{
				hiddenValue = Encrypt(InternalDecrypt(), cryptoKey);
				currentCryptoKey = cryptoKey;
			}
		}
Пример #27
0
 public void SetEncrypted(RawEncryptedVector3 encrypted)
 {
 }
Пример #28
0
 /// <summary>
 /// Use it to decrypt RawEncryptedVector3 you got from Encrypt(), uses default crypto key.
 /// </summary>
 public static Vector3 Decrypt(RawEncryptedVector3 value)
 {
     return(Decrypt(value, 0));
 }
Пример #29
0
		/// <summary>
		/// Allows to explicitly set current obscured value.
		/// </summary>
		/// Use it in conjunction with GetEncrypted().<br/>
		/// Useful for loading data stored in obscured state.
		public void SetEncrypted(RawEncryptedVector3 encrypted)
		{
			inited = true;
			hiddenValue = encrypted;
			if (Detectors.ObscuredCheatingDetector.isRunning)
			{
				fakeValue = InternalDecrypt();
			}
		}
 /// <summary>
 /// Allows to explicitly set current obscured value.
 /// </summary>
 /// Use it in conjunction with GetEncrypted().<br/>
 /// Useful for loading data stored in obscured state.
 public void SetEncrypted(RawEncryptedVector3 encrypted)
 {
     inited      = true;
     hiddenValue = encrypted;
 }
Пример #31
0
 public static Vector3 Decrypt(RawEncryptedVector3 value)
 {
     throw new Exception();
 }
Пример #32
0
		private Vector3 InternalDecrypt()
		{
			if (!inited)
			{
				currentCryptoKey = cryptoKey;
				hiddenValue = Encrypt(initialFakeValue, cryptoKey);
				fakeValue = initialFakeValue;
				inited = true;
			}

			int key = cryptoKey;

			if (currentCryptoKey != cryptoKey)
			{
				key = currentCryptoKey;
			}

			Vector3 value;

			value.x = ObscuredFloat.Decrypt(hiddenValue.x, key);
			value.y = ObscuredFloat.Decrypt(hiddenValue.y, key);
			value.z = ObscuredFloat.Decrypt(hiddenValue.z, key);

			if (Detectors.ObscuredCheatingDetector.isRunning && !fakeValue.Equals(Vector3.zero) && !CompareVectorsWithTolerance(value, fakeValue))
			{
				Detectors.ObscuredCheatingDetector.Instance.OnCheatingDetected();
			}

			return value;
		}
Пример #33
0
		/// <summary>
		/// Use it to decrypt RawEncryptedVector3 you got from Encrypt(), uses default crypto key.
		/// </summary>
		public static Vector3 Decrypt(RawEncryptedVector3 value)
		{
			return Decrypt(value, 0);
		}
Пример #34
0
		/// <summary>
		/// Use it to decrypt RawEncryptedVector3 you got from Encrypt(), uses passed crypto key.
		/// </summary>
		public static Vector3 Decrypt(RawEncryptedVector3 value, int key)
		{
			if (key == 0)
			{
				key = cryptoKey;
			}

			Vector3 result;
			result.x = ObscuredFloat.Decrypt(value.x, key);
			result.y = ObscuredFloat.Decrypt(value.y, key);
			result.z = ObscuredFloat.Decrypt(value.z, key);

			return result;
		}