/// <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; }
/// <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); }
/// <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); }
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); }
/// <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); }
private ObscuredVector3(RawEncryptedVector3 encrypted) { currentCryptoKey = cryptoKey; hiddenValue = encrypted; fakeValue = initialFakeValue; 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(); currentCryptoKey = ThreadSafeRandom.Next(); hiddenValue = Encrypt(decrypted, currentCryptoKey); }
public void RandomizeCryptoKey() { var decrypted = InternalDecrypt(); currentCryptoKey = GenerateKey(); hiddenValue = Encrypt(decrypted, currentCryptoKey); }
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); }
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); }
public void SetEncryptedDeprecated(Vector3 encrypted) { hiddenValue = (RawEncryptedVector3)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(RawEncryptedVector3 encrypted) { inited = true; hiddenValue = encrypted; if (Detectors.ObscuredCheatingDetector.IsRunning) { fakeValue = InternalDecrypt(); } }
/// <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); }
/// <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> /// 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; } }
private ObscuredVector3(Vector3 value) { currentCryptoKey = cryptoKey; hiddenValue = Encrypt(value); bool detectorRunning = Detectors.ObscuredCheatingDetector.IsRunning; fakeValue = detectorRunning ? value : zero; fakeValueActive = detectorRunning; inited = true; }
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; }
/// <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; } }
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); }
/// <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; }
/// <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; }
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); }
public void SetEncrypted(RawEncryptedVector3 encrypted) { }
/// <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)); }
/// <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; }
public static Vector3 Decrypt(RawEncryptedVector3 value) { throw new Exception(); }
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; }
/// <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); }
/// <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; }