private Vector2Int InternalDecrypt() { if (!inited) { currentCryptoKey = cryptoKey; hiddenValue = Encrypt(zero); fakeValue = zero; fakeValueActive = false; inited = true; return(zero); } var value = new Vector2Int { x = ObscuredInt.Decrypt(hiddenValue.x, currentCryptoKey), y = ObscuredInt.Decrypt(hiddenValue.y, currentCryptoKey) }; if (Detectors.ObscuredCheatingDetector.ExistsAndIsRunning && fakeValueActive && value != fakeValue) { Detectors.ObscuredCheatingDetector.Instance.OnCheatingDetected(); } return(value); }
/// <summary> /// Encrypts passed components using passed key. /// </summary> /// Key can be generated automatically using GenerateKey(). /// \sa Decrypt(), GenerateKey() public static RawEncryptedVector2Int Encrypt(int x, int y, int key) { RawEncryptedVector2Int result; result.x = ObscuredInt.Encrypt(x, key); result.y = ObscuredInt.Encrypt(y, key); return(result); }
/// <summary> /// Decrypts passed value you got from Encrypt() using same key. /// </summary> /// \sa Encrypt() public static Vector2Int Decrypt(RawEncryptedVector2Int value, int key) { var result = new Vector2Int { x = ObscuredInt.Decrypt(value.x, key), y = ObscuredInt.Decrypt(value.y, key) }; return(result); }
private int InternalDecryptField(int encrypted) { var key = cryptoKey; if (currentCryptoKey != cryptoKey) { key = currentCryptoKey; } var result = ObscuredInt.Decrypt(encrypted, key); return(result); }
/// <summary> /// Use this simple encryption method to encrypt Vector3Int components, uses passed crypto key. /// </summary> public static RawEncryptedVector3Int Encrypt(int x, int y, int z, int key) { if (key == 0) { key = cryptoKey; } RawEncryptedVector3Int result; result.x = ObscuredInt.Encrypt(x, key); result.y = ObscuredInt.Encrypt(y, key); result.z = ObscuredInt.Encrypt(z, key); return(result); }
/// <summary> /// Use it to decrypt RawEncryptedVector3Int you got from Encrypt(), uses passed crypto key. /// </summary> public static Vector3Int Decrypt(RawEncryptedVector3Int value, int key) { if (key == 0) { key = cryptoKey; } var result = new Vector3Int { x = ObscuredInt.Decrypt(value.x, key), y = ObscuredInt.Decrypt(value.y, key), z = ObscuredInt.Decrypt(value.z, key) }; return(result); }
private int InternalEncryptField(int encrypted) { var result = ObscuredInt.Encrypt(encrypted, cryptoKey); return(result); }