/// <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); }
public void RandomizeCryptoKey() { Vector3 value = this.InternalDecrypt(); this.currentCryptoKey = UnityEngine.Random.Range(-2147483648, 2147483647); this.hiddenValue = ObscuredVector3.Encrypt(value, this.currentCryptoKey); }
public void UseObscured() { useRegular = false; obscuredPlayerPosition += new Vector3(Random.Range(-10f, 50f), Random.Range(-10f, 50f), Random.Range(-10f, 50f)); playerPosition = new Vector3(10.5f, 11.5f, 12.5f); ; Debug.Log("Try to change this Vector3 in memory:\n" + obscuredPlayerPosition); }
public void RandomizeCryptoKey() { Vector3 vector3 = this.InternalDecrypt(); this.currentCryptoKey = Random.get_seed(); this.hiddenValue = ObscuredVector3.Encrypt(vector3, this.currentCryptoKey); }
public void ApplyNewCryptoKey() { if (this.currentCryptoKey != ObscuredVector3.cryptoKey) { this.hiddenValue = ObscuredVector3.Encrypt(this.InternalDecrypt(), ObscuredVector3.cryptoKey); this.currentCryptoKey = ObscuredVector3.cryptoKey; } }
private void Start() { Debug.Log("===== ObscuredVector3Test =====\n"); // example of custom crypto key using // this is not necessary! key is 120205 by default ObscuredVector3.SetNewCryptoKey(404); // just a small self-test here playerPosition = new Vector3(54.1f,64.3f,63.2f); Debug.Log("Original position:\n" + playerPosition); obscuredPlayerPosition = playerPosition; //Vector3 encrypted = obscuredPlayerPosition.GetEncrypted(); ObscuredVector3.RawEncryptedVector3 encrypted = obscuredPlayerPosition.GetEncrypted(); Debug.Log("How your position is stored in memory when obscured:\n(" + encrypted.x + ", " + encrypted.y + ", " + encrypted.z + ")"); }
private Vector3 InternalDecrypt() { if (!this.inited) { this.currentCryptoKey = ObscuredVector3.cryptoKey; this.hiddenValue = ObscuredVector3.Encrypt(ObscuredVector3.initialFakeValue, ObscuredVector3.cryptoKey); this.fakeValue = ObscuredVector3.initialFakeValue; this.inited = true; } Vector3 vector; vector.x = ObscuredFloat.Decrypt(this.hiddenValue.x, this.currentCryptoKey); vector.y = ObscuredFloat.Decrypt(this.hiddenValue.y, this.currentCryptoKey); vector.z = ObscuredFloat.Decrypt(this.hiddenValue.z, this.currentCryptoKey); if (ObscuredCheatingDetector.IsRunning && !this.fakeValue.Equals(Vector3.zero) && !this.CompareVectorsWithTolerance(vector, this.fakeValue)) { ObscuredCheatingDetector.Instance.OnCheatingDetected(); } return(vector); }
private Vector3 InternalDecrypt() { if (!this.inited) { this.currentCryptoKey = ObscuredVector3.cryptoKey; this.hiddenValue = ObscuredVector3.Encrypt(ObscuredVector3.initialFakeValue, ObscuredVector3.cryptoKey); this.fakeValue = ObscuredVector3.initialFakeValue; this.inited = true; } Vector3 vector1; vector1.x = (__Null)(double)ObscuredFloat.Decrypt(this.hiddenValue.x, this.currentCryptoKey); vector1.y = (__Null)(double)ObscuredFloat.Decrypt(this.hiddenValue.y, this.currentCryptoKey); vector1.z = (__Null)(double)ObscuredFloat.Decrypt(this.hiddenValue.z, this.currentCryptoKey); // ISSUE: explicit reference operation if (ObscuredCheatingDetector.IsRunning && !((Vector3)@this.fakeValue).Equals((object)Vector3.get_zero()) && !this.CompareVectorsWithTolerance(vector1, this.fakeValue)) { ObscuredCheatingDetector.Instance.OnCheatingDetected(); } return(vector1); }
public static Vector3 Decrypt(ObscuredVector3.RawEncryptedVector3 value) { return(ObscuredVector3.Decrypt(value, 0)); }
public static ObscuredVector3.RawEncryptedVector3 Encrypt(Vector3 value) { return(ObscuredVector3.Encrypt(value, 0)); }