private ObscuredQuaternion(RawEncryptedQuaternion value) { currentCryptoKey = cryptoKey; hiddenValue = value; fakeValue = initialFakeValue; inited = true; }
private ObscuredQuaternion(Quaternion value) { currentCryptoKey = cryptoKey; hiddenValue = Encrypt(value); inited = true; }
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); }
/// <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; }
public void RandomizeCryptoKey() { var decrypted = InternalDecrypt(); currentCryptoKey = GenerateKey(); hiddenValue = Encrypt(decrypted, currentCryptoKey); }
/// <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); }
/// <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); }
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; } }
public void SetEncryptedDeprecated(Quaternion encrypted) { hiddenValue = (RawEncryptedQuaternion)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 (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; } }
/// <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; }
/// <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); }
/// <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); }
private ObscuredQuaternion(Quaternion value) { currentCryptoKey = cryptoKey; hiddenValue = Encrypt(value); var detectorRunning = Detectors.ObscuredCheatingDetector.ExistsAndIsRunning; fakeValue = detectorRunning ? value : identity; fakeValueActive = detectorRunning; inited = true; }
/// <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; }
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; }
/// <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); }
/// <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; }
/// <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; }
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); }
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); }
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(); } }
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)); }
/// <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; }