private ObscuredQuaternion(RawEncryptedQuaternion value)
		{
			currentCryptoKey = cryptoKey;
			hiddenValue = value;
			fakeValue = initialFakeValue;
			inited = true;
		}
        private ObscuredQuaternion(Quaternion value)
        {
            currentCryptoKey = cryptoKey;
            hiddenValue      = Encrypt(value);

            inited = true;
        }
Пример #3
0
        private Quaternion InternalDecrypt()
        {
            if (!inited)
            {
                currentCryptoKey = cryptoKey;
                hiddenValue      = Encrypt(identity);
                fakeValue        = identity;
                fakeValueActive  = false;
                inited           = true;

                return(identity);
            }

            Quaternion value;

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

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

            return(value);
        }
        /// <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()
        {
            Quaternion decrypted = InternalDecrypt();

            currentCryptoKey = Random.Range(int.MinValue, int.MaxValue);
            hiddenValue      = Encrypt(decrypted, currentCryptoKey);
        }
Пример #5
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);
        }
        /// <summary>
        /// Mimics constructor of regular Quaternion. Please note, passed components are not Euler Angles.
        /// </summary>
        /// <param name="x">X component of the quaternion</param>
        /// <param name="y">Y component of the quaternion</param>
        /// <param name="z">Z component of the quaternion</param>
        /// <param name="w">W component of the quaternion</param>
        public ObscuredQuaternion(float x, float y, float z, float w)
        {
            currentCryptoKey = cryptoKey;
            hiddenValue      = Encrypt(x, y, z, w, currentCryptoKey);

            inited = true;
        }
Пример #7
0
        public void RandomizeCryptoKey()
        {
            var decrypted = InternalDecrypt();

            currentCryptoKey = GenerateKey();
            hiddenValue      = Encrypt(decrypted, currentCryptoKey);
        }
Пример #8
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.
        ///
        /// <param name="encrypted">Raw encrypted value you got from GetEncrypted().</param>
        /// <param name="key">Encryption key you've got from GetEncrypted().</param>
        /// <returns>New obscured variable initialized from specified encrypted value.</returns>
        /// \sa GetEncrypted(), SetEncrypted()
        public static ObscuredQuaternion FromEncrypted(RawEncryptedQuaternion encrypted, int key)
        {
            var instance = new ObscuredQuaternion();

            instance.SetEncrypted(encrypted, key);
            return(instance);
        }
 private ObscuredQuaternion(RawEncryptedQuaternion value)
 {
     currentCryptoKey = cryptoKey;
     hiddenValue      = value;
     fakeValue        = initialFakeValue;
     inited           = true;
 }
Пример #10
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()
        {
            Quaternion decrypted = InternalDecrypt();

            currentCryptoKey = Random.seed;
            hiddenValue      = Encrypt(decrypted, currentCryptoKey);
        }
Пример #11
0
        private Quaternion InternalDecrypt()
        {
            if (!inited)
            {
                currentCryptoKey = cryptoKey;
                hiddenValue      = Encrypt(initialFakeValue);
                fakeValue        = initialFakeValue;
                inited           = true;
            }

            int key = cryptoKey;

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

            Quaternion value;

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

            if (Detectors.ObscuredCheatingDetector.isRunning && !fakeValue.Equals(initialFakeValue) && !CompareQuaternionsWithTolerance(value, fakeValue))
            {
                Detectors.ObscuredCheatingDetector.Instance.OnCheatingDetected();
            }

            return(value);
        }
Пример #12
0
        private Quaternion InternalDecrypt()
        {
            if (!inited)
            {
                currentCryptoKey = cryptoKey;
                hiddenValue      = Encrypt(initialFakeValue);
                inited           = true;
            }

            int key = cryptoKey;

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

            Quaternion value;

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


            return(value);
        }
		/// <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;
			}
		}
Пример #14
0
 public void SetEncryptedDeprecated(Quaternion encrypted)
 {
     hiddenValue = (RawEncryptedQuaternion)encrypted;
     if (Detectors.ObscuredCheatingDetector.isRunning)
     {
         fakeValue = InternalDecrypt();
     }
 }
 /// <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;
     }
 }
 /// <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(RawEncryptedQuaternion 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(RawEncryptedQuaternion encrypted)
        {
            inited      = true;
            hiddenValue = encrypted;

            if (currentCryptoKey == 0)
            {
                currentCryptoKey = cryptoKey;
            }
        }
Пример #18
0
 /// <summary>
 /// Mimics constructor of regular Quaternion. Please note, passed components are not Euler Angles.
 /// </summary>
 /// <param name="x">X component of the quaternion</param>
 /// <param name="y">Y component of the quaternion</param>
 /// <param name="z">Z component of the quaternion</param>
 /// <param name="w">W component of the quaternion</param>
 public ObscuredQuaternion(float x, float y, float z, float w)
 {
     currentCryptoKey = cryptoKey;
     hiddenValue      = Encrypt(x, y, z, w, currentCryptoKey);
     fakeValue.x      = x;
     fakeValue.y      = y;
     fakeValue.z      = z;
     fakeValue.w      = w;
     inited           = true;
 }
Пример #19
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);
        }
Пример #20
0
        /// <summary>
        /// Decrypts passed value you got from Encrypt() using same key.
        /// </summary>
        /// \sa Encrypt()
        public static Quaternion Decrypt(RawEncryptedQuaternion value, int key)
        {
            Quaternion result;

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

            return(result);
        }
Пример #21
0
        private ObscuredQuaternion(Quaternion value)
        {
            currentCryptoKey = cryptoKey;
            hiddenValue      = Encrypt(value);

            var detectorRunning = Detectors.ObscuredCheatingDetector.ExistsAndIsRunning;

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

            inited = true;
        }
Пример #22
0
        /// <summary>
        /// Use it to decrypt RawEncryptedQuaternion you got from Encrypt(), uses passed crypto key.
        /// </summary>
        public static Quaternion Decrypt(RawEncryptedQuaternion value, int key)
        {
            if (key == 0)
            {
                key = cryptoKey;
            }

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

            return result;
        }
Пример #23
0
        private ObscuredQuaternion(Quaternion 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 : Identity;
            fakeValueActive = detectorRunning;
#endif
            inited = true;
        }
Пример #24
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(RawEncryptedQuaternion encrypted, int key)
        {
            inited           = true;
            hiddenValue      = encrypted;
            currentCryptoKey = key;

            if (Detectors.ObscuredCheatingDetector.ExistsAndIsRunning)
            {
                fakeValueActive = false;
                fakeValue       = InternalDecrypt();
                fakeValueActive = true;
            }
            else
            {
                fakeValueActive = false;
            }
        }
        private Quaternion InternalDecrypt()
        {
            if (!inited)
            {
                currentCryptoKey = cryptoKey;
                hiddenValue      = Encrypt(identity);
                inited           = true;

                return(identity);
            }

            Quaternion value;

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

            return(value);
        }
Пример #26
0
        /// <summary>
        /// Mimics constructor of regular Quaternion. Please note, passed components are not Euler Angles.
        /// </summary>
        /// <param name="x">X component of the quaternion</param>
        /// <param name="y">Y component of the quaternion</param>
        /// <param name="z">Z component of the quaternion</param>
        /// <param name="w">W component of the quaternion</param>
        public ObscuredQuaternion(float x, float y, float z, float w)
        {
            currentCryptoKey = cryptoKey;
            hiddenValue      = Encrypt(x, y, z, w, currentCryptoKey);

            if (Detectors.ObscuredCheatingDetector.ExistsAndIsRunning)
            {
                fakeValue.x     = x;
                fakeValue.y     = y;
                fakeValue.z     = z;
                fakeValue.w     = w;
                fakeValueActive = true;
            }
            else
            {
                fakeValue       = identity;
                fakeValueActive = false;
            }

            inited = true;
        }
Пример #27
0
        /// <summary>
        /// Mimics constructor of regular Quaternion. Please note, passed components are not Euler Angles.
        /// </summary>
        /// <param name="x">X component of the quaternion</param>
        /// <param name="y">Y component of the quaternion</param>
        /// <param name="z">Z component of the quaternion</param>
        /// <param name="w">W component of the quaternion</param>
        public ObscuredQuaternion(float x, float y, float z, float w)
        {
            currentCryptoKey = GenerateKey();
            hiddenValue      = Encrypt(x, y, z, w, currentCryptoKey);

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

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

                return(Identity);
            }

            var decrypted = Decrypt(hiddenValue, currentCryptoKey);

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

            return(decrypted);
        }
Пример #29
0
 public static Quaternion Decrypt(RawEncryptedQuaternion value)
 {
     throw new Exception();
 }
		/// <summary>
		/// Use it to decrypt RawEncryptedQuaternion you got from Encrypt(), uses default crypto key.
		/// </summary>
		public static Quaternion Decrypt(RawEncryptedQuaternion value)
		{
			return Decrypt(value, 0);
		}
Пример #31
0
 public void SetEncrypted(RawEncryptedQuaternion encrypted)
 {
 }
		/// <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(RawEncryptedQuaternion encrypted)
		{
			inited = true;
			hiddenValue = encrypted;
			if (Detectors.ObscuredCheatingDetector.isRunning)
			{
				fakeValue = InternalDecrypt();
			}
		}
Пример #33
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()
        {
            Quaternion decrypted = InternalDecrypt();

            currentCryptoKey = Random.seed;
            hiddenValue = Encrypt(decrypted, currentCryptoKey);
        }
		private Quaternion InternalDecrypt()
		{
			if (!inited)
			{
				currentCryptoKey = cryptoKey;
				hiddenValue = Encrypt(initialFakeValue);
				fakeValue = initialFakeValue;
				inited = true;
			}

			int key = cryptoKey;

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

			Quaternion value;

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

			if (Detectors.ObscuredCheatingDetector.isRunning && !fakeValue.Equals(initialFakeValue) && !CompareQuaternionsWithTolerance(value, fakeValue))
			{
				Detectors.ObscuredCheatingDetector.Instance.OnCheatingDetected();
			}

			return value;
		}
 /// <summary>
 /// Use it to decrypt RawEncryptedQuaternion you got from Encrypt(), uses default crypto key.
 /// </summary>
 public static Quaternion Decrypt(RawEncryptedQuaternion value)
 {
     return(Decrypt(value, 0));
 }
Пример #36
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(RawEncryptedQuaternion encrypted)
 {
     inited      = true;
     hiddenValue = encrypted;
 }