private float InternalDecrypt()
        {
            if (!inited)
            {
                currentCryptoKey = cryptoKey;
                hiddenValue      = InternalEncrypt(0);
                fakeValue        = 0;
                inited           = true;
            }

            var union = new FloatIntBytesUnion();

            union.b4 = hiddenValue;

            union.i = union.i ^ currentCryptoKey;

            float decrypted = union.f;

            if (Detectors.ObscuredCheatingDetector.IsRunning && fakeValue != 0 && Math.Abs(decrypted - fakeValue) > Detectors.ObscuredCheatingDetector.Instance.floatEpsilon)
            {
                Detectors.ObscuredCheatingDetector.Instance.OnCheatingDetected();
            }

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

            currentCryptoKey = Random.Range(int.MinValue, int.MaxValue);
            hiddenValue      = InternalEncrypt(decrypted, currentCryptoKey);
        }
Ejemplo n.º 3
0
 private ObscuredFloat(ACTkByte4 PDGAOEAMDCL)
 {
     this.currentCryptoKey = ObscuredFloat.cryptoKey;
     this.hiddenValue      = PDGAOEAMDCL;
     this.hiddenValueOld   = 0;
     this.inited           = true;
 }
 /// <summary>
 /// Use it after SetNewCryptoKey() to re-encrypt current instance using new crypto key.
 /// </summary>
 public void ApplyNewCryptoKey()
 {
     if (currentCryptoKey != cryptoKey)
     {
         hiddenValue      = InternalEncrypt(InternalDecrypt(), cryptoKey);
         currentCryptoKey = cryptoKey;
     }
 }
 private ObscuredFloat(ACTkByte4 value)
 {
     currentCryptoKey = cryptoKey;
     hiddenValue      = value;
     hiddenValueOld   = null;
     fakeValue        = 0;
     inited           = true;
 }
        private ObscuredFloat(float value)
        {
            currentCryptoKey = cryptoKey;
            hiddenValue      = InternalEncrypt(value);
            hiddenValueOld   = null;

            inited = true;
        }
Ejemplo n.º 7
0
 public void SetEncrypted(int LEBNEIHLING)
 {
     this.inited      = true;
     this.hiddenValue = new ObscuredFloat.CLIIHCHMDEK()
     {
         i = LEBNEIHLING
     }.b4;
 }
Ejemplo n.º 8
0
 public void ApplyNewCryptoKey()
 {
     if (this.currentCryptoKey == ObscuredFloat.cryptoKey)
     {
         return;
     }
     this.hiddenValue      = ObscuredFloat.InternalEncrypt(this.InternalDecrypt(), ObscuredFloat.cryptoKey);
     this.currentCryptoKey = ObscuredFloat.cryptoKey;
 }
Ejemplo n.º 9
0
        public void RandomizeCryptoKey()
        {
            float PDGAOEAMDCL = this.InternalDecrypt();

            do
            {
                this.currentCryptoKey = 0;
            }while (this.currentCryptoKey == 0);
            this.hiddenValue = ObscuredFloat.InternalEncrypt(PDGAOEAMDCL, this.currentCryptoKey);
        }
        /// <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 = InternalEncrypt(decrypted, currentCryptoKey);
        }
Ejemplo n.º 11
0
 private float InternalDecrypt()
 {
     if (!this.inited)
     {
         this.currentCryptoKey = ObscuredFloat.cryptoKey;
         this.hiddenValue      = ObscuredFloat.InternalEncrypt(0.0f);
         this.inited           = true;
     }
     ObscuredFloat.CLIIHCHMDEK cliihchmdek = new ObscuredFloat.CLIIHCHMDEK();
     cliihchmdek.b4 = this.hiddenValue;
     cliihchmdek.i ^= this.currentCryptoKey;
     return(cliihchmdek.f);
 }
Ejemplo n.º 12
0
        private ObscuredFloat(float value)
        {
            currentCryptoKey = cryptoKey;
            hiddenValue      = InternalEncrypt(value);
            hiddenValueOld   = null;

            bool detectorRunning = Detectors.ObscuredCheatingDetector.IsRunning;

            fakeValue       = detectorRunning ? value : 0f;
            fakeValueActive = detectorRunning;

            inited = true;
        }
Ejemplo n.º 13
0
        private ObscuredFloat(float value)
        {
            currentCryptoKey    = cryptoKey;
            hiddenValue         = InternalEncrypt(value);
            hiddenValueOldByte4 = default(ACTkByte4);

            var detectorRunning = Detectors.ObscuredCheatingDetector.ExistsAndIsRunning;

            fakeValue       = detectorRunning ? value : 0f;
            fakeValueActive = detectorRunning;

            inited = true;
        }
Ejemplo n.º 14
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(int encrypted)
        {
            inited = true;
            FloatIntBytesUnion union = new FloatIntBytesUnion();

            union.i = encrypted;

            hiddenValue = union.b4;

            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(int encrypted)
        {
            inited = true;
            var union = new FloatIntBytesUnion();

            union.i = encrypted;

            hiddenValue = union.b4;

            if (currentCryptoKey == 0)
            {
                currentCryptoKey = cryptoKey;
            }
        }
Ejemplo n.º 16
0
        private ObscuredFloat(float value)
        {
            currentCryptoKey    = GenerateKey();
            hiddenValue         = Encrypt(value, currentCryptoKey);
            hiddenValueOldByte4 = default(ACTkByte4);

#if UNITY_EDITOR
            fakeValue       = value;
            fakeValueActive = true;
            migratedVersion = null;
#else
            var detectorRunning = Detectors.ObscuredCheatingDetector.ExistsAndIsRunning;
            fakeValue       = detectorRunning ? value : 0f;
            fakeValueActive = detectorRunning;
#endif
            inited = true;
        }
        private float InternalDecrypt()
        {
            if (!inited)
            {
                currentCryptoKey = cryptoKey;
                hiddenValue      = InternalEncrypt(0);
                inited           = true;

                return(0);
            }

            var union = new FloatIntBytesUnion();

            union.b4 = hiddenValue;

            union.i = union.i ^ currentCryptoKey;

            var decrypted = union.f;

            return(decrypted);
        }