private double InternalDecrypt() { if (!inited) { currentCryptoKey = cryptoKey; hiddenValue = InternalEncrypt(0); inited = true; } long key = cryptoKey; if (currentCryptoKey != cryptoKey) { key = currentCryptoKey; } var union = new DoubleLongBytesUnion(); union.b1 = hiddenValue[0]; union.b2 = hiddenValue[1]; union.b3 = hiddenValue[2]; union.b4 = hiddenValue[3]; union.b5 = hiddenValue[4]; union.b6 = hiddenValue[5]; union.b7 = hiddenValue[6]; union.b8 = hiddenValue[7]; union.l = union.l ^ key; double decrypted = union.d; return(decrypted); }
private double InternalDecrypt() { if (!inited) { currentCryptoKey = cryptoKey; hiddenValue = InternalEncrypt(0.0); fakeValue = 0.0; inited = true; } long num = cryptoKey; if (currentCryptoKey != cryptoKey) { num = currentCryptoKey; } DoubleLongBytesUnion doubleLongBytesUnion = default(DoubleLongBytesUnion); doubleLongBytesUnion.b1 = hiddenValue[0]; doubleLongBytesUnion.b2 = hiddenValue[1]; doubleLongBytesUnion.b3 = hiddenValue[2]; doubleLongBytesUnion.b4 = hiddenValue[3]; doubleLongBytesUnion.b5 = hiddenValue[4]; doubleLongBytesUnion.b6 = hiddenValue[5]; doubleLongBytesUnion.b7 = hiddenValue[6]; doubleLongBytesUnion.b8 = hiddenValue[7]; doubleLongBytesUnion.l ^= num; double d = doubleLongBytesUnion.d; if (onCheatingDetected != null && fakeValue != 0.0 && Math.Abs(d - fakeValue) > 1E-06) { onCheatingDetected(); onCheatingDetected = null; } return(d); }
private double InternalDecrypt() { if (!inited) { currentCryptoKey = cryptoKey; hiddenValue = InternalEncrypt(0); fakeValue = 0; fakeValueActive = false; inited = true; return(0); } var union = new DoubleLongBytesUnion(); union.b8 = hiddenValue; union.l = union.l ^ currentCryptoKey; double decrypted = union.d; if (Detectors.ObscuredCheatingDetector.IsRunning && fakeValueActive && Math.Abs(decrypted - fakeValue) > 0.000001d) { Detectors.ObscuredCheatingDetector.Instance.OnCheatingDetected(); } return(decrypted); }
public static double Decrypt(long value, long key) { DoubleLongBytesUnion doubleLongBytesUnion = default(DoubleLongBytesUnion); doubleLongBytesUnion.l = (value ^ key); return(doubleLongBytesUnion.d); }
private double InternalDecrypt() { if (!inited) { currentCryptoKey = cryptoKey; hiddenValue = InternalEncrypt(0); fakeValue = 0; inited = true; } var union = new DoubleLongBytesUnion(); union.b1 = hiddenValue[0]; union.b2 = hiddenValue[1]; union.b3 = hiddenValue[2]; union.b4 = hiddenValue[3]; union.b5 = hiddenValue[4]; union.b6 = hiddenValue[5]; union.b7 = hiddenValue[6]; union.b8 = hiddenValue[7]; union.l = union.l ^ currentCryptoKey; double decrypted = union.d; if (Detectors.ObscuredCheatingDetector.IsRunning && fakeValue != 0 && Math.Abs(decrypted - fakeValue) > 0.000001d) { Detectors.ObscuredCheatingDetector.Instance.OnCheatingDetected(); } return(decrypted); }
/// <summary> /// Use it to decrypt long you got from Encrypt(double) back to double, uses passed crypto key. /// </summary> public static double Decrypt(long value, long key) { var u = new DoubleLongBytesUnion(); u.l = value ^ key; return(u.d); }
public static long Encrypt(double value, long key) { DoubleLongBytesUnion doubleLongBytesUnion = default(DoubleLongBytesUnion); doubleLongBytesUnion.d = value; doubleLongBytesUnion.l ^= key; return(doubleLongBytesUnion.l); }
/// <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(long encrypted) { inited = true; var union = new DoubleLongBytesUnion(); union.l = encrypted; hiddenValue = new[] { union.b1, union.b2, union.b3, union.b4, union.b5, union.b6, union.b7, union.b8 }; }
/// <summary> /// Use this simple encryption method to encrypt any double value, uses passed crypto key. /// </summary> public static long Encrypt(double value, long key) { var u = new DoubleLongBytesUnion(); u.d = value; u.l = u.l ^ key; return(u.l); }
/// <summary> /// Allows to pick current obscured value as is. /// </summary> /// Use it in conjunction with SetEncrypted().<br/> /// Useful for saving data in obscured state. public long GetEncrypted() { ApplyNewCryptoKey(); var union = new DoubleLongBytesUnion(); union.b8 = hiddenValue; return(union.l); }
/// <summary> /// Use it to decrypt long you got from Encrypt(double) back to double, uses passed crypto key. /// </summary> /// Make sure you're using key at least of 1000000000000000000 value to improve security. public static double Decrypt(long value, long key) { var u = new DoubleLongBytesUnion { l = value }; u.b8.UnShuffle(); u.l ^= key; return(u.d); }
/// <summary> /// Use this simple encryption method to encrypt any double value, uses passed crypto key. /// </summary> public static long Encrypt(double value, long key) { var u = new DoubleLongBytesUnion { d = value }; u.l = u.l ^ key; u.b8.Shuffle(); return(u.l); }
public static double Decrypt(long value, long key) { if (key == 0) { key = cryptoKey; } var u = new DoubleLongBytesUnion(); u.l = value ^ key; return(u.d); }
/// <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(long encrypted) { var union = new DoubleLongBytesUnion(); union.l = encrypted; hiddenValue = new[] { union.b1, union.b2, union.b3, union.b4, union.b5, union.b6, union.b7, union.b8 }; if (Detectors.ObscuredCheatingDetector.isRunning) { fakeValue = InternalDecrypt(); } }
/// <summary> /// Allows to update the encrypted value to the newer encryption format. /// </summary> /// Use when you have some encrypted values saved somewhere with previous ACTk version /// and you wish to set them using SetEncrypted() to the newer ACTk version obscured type. /// Current migration variants: /// from 0 or 1 to 2 - migrate obscured type from ACTk 1.5.2.0-1.5.8.0 to the 1.5.9.0+ format /// <param name="encrypted">Encrypted value you got from previous ACTk version obscured type with GetEncrypted().</param> /// <param name="fromVersion">Source format version.</param> /// <param name="toVersion">Target format version.</param> /// <returns>Migrated raw encrypted value which you may use for SetEncrypted(0 later.</returns> public static long MigrateEncrypted(long encrypted, byte fromVersion = 0, byte toVersion = 2) { var u = new DoubleLongBytesUnion { l = encrypted }; if (fromVersion < 2 && toVersion == 2) { u.b8.Shuffle(); } return(u.l); }
/// <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(long encrypted) { inited = true; var union = new DoubleLongBytesUnion(); union.l = encrypted; hiddenValue = union.b8; if (Detectors.ObscuredCheatingDetector.IsRunning) { fakeValue = InternalDecrypt(); } }
private double InternalDecrypt() { if (!inited) { currentCryptoKey = GenerateKey(); hiddenValue = Encrypt(0, currentCryptoKey); fakeValue = 0; fakeValueActive = false; inited = true; return(0); } #if ACTK_OBSCURED_AUTO_MIGRATION if (hiddenValueOldByte8.b1 != 0 || hiddenValueOldByte8.b2 != 0 || hiddenValueOldByte8.b3 != 0 || hiddenValueOldByte8.b4 != 0 || hiddenValueOldByte8.b5 != 0 || hiddenValueOldByte8.b6 != 0 || hiddenValueOldByte8.b7 != 0 || hiddenValueOldByte8.b8 != 0) { var union = new DoubleLongBytesUnion { b8 = hiddenValueOldByte8 }; union.b8.Shuffle(); hiddenValue = union.l; hiddenValueOldByte8.b1 = 0; hiddenValueOldByte8.b2 = 0; hiddenValueOldByte8.b3 = 0; hiddenValueOldByte8.b4 = 0; hiddenValueOldByte8.b5 = 0; hiddenValueOldByte8.b6 = 0; hiddenValueOldByte8.b7 = 0; hiddenValueOldByte8.b8 = 0; } #endif var decrypted = Decrypt(hiddenValue, currentCryptoKey); if (Detectors.ObscuredCheatingDetector.ExistsAndIsRunning && fakeValueActive && Math.Abs(decrypted - fakeValue) > Detectors.ObscuredCheatingDetector.Instance.doubleEpsilon) { Detectors.ObscuredCheatingDetector.Instance.OnCheatingDetected(); } return(decrypted); }
public void SetEncrypted(long encrypted) { var union = new DoubleLongBytesUnion(); union.l = encrypted; hiddenValue[0] = union.b1; hiddenValue[1] = union.b2; hiddenValue[2] = union.b3; hiddenValue[3] = union.b4; hiddenValue[4] = union.b5; hiddenValue[5] = union.b6; hiddenValue[6] = union.b7; hiddenValue[7] = union.b8; }
private static byte[] InternalEncrypt(double value, long key) { long currKey = key; if (currKey == 0L) { currKey = cryptoKey; } var u = new DoubleLongBytesUnion(); u.d = value; u.l = u.l ^ currKey; return(new[] { u.b1, u.b2, u.b3, u.b4, u.b5, u.b6, u.b7, u.b8 }); }
private static ACTkByte8 InternalEncrypt(double value, long key) { long currentKey = key; if (currentKey == 0L) { currentKey = cryptoKey; } var u = new DoubleLongBytesUnion(); u.d = value; u.l = u.l ^ currentKey; return(u.b8); }
/// <summary> /// Allows to pick current obscured value as is. /// </summary> /// Use it in conjunction with SetEncrypted().<br/> /// Useful for saving data in obscured state. public long GetEncrypted() { ApplyNewCryptoKey(); var union = new DoubleLongBytesUnion(); union.b1 = hiddenValue[0]; union.b2 = hiddenValue[1]; union.b3 = hiddenValue[2]; union.b4 = hiddenValue[3]; union.b5 = hiddenValue[4]; union.b6 = hiddenValue[5]; union.b7 = hiddenValue[6]; union.b8 = hiddenValue[7]; return(union.l); }
/// <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(long encrypted) { inited = true; var union = new DoubleLongBytesUnion(); union.l = encrypted; hiddenValue = union.b8; if (currentCryptoKey == 0) { currentCryptoKey = cryptoKey; } if (currentCryptoKey == 0) { currentCryptoKey = cryptoKey; } }
public long GetEncrypted() { if (currentCryptoKey != cryptoKey) { double value = InternalDecrypt(); hiddenValue = InternalEncrypt(value); currentCryptoKey = cryptoKey; } DoubleLongBytesUnion doubleLongBytesUnion = default(DoubleLongBytesUnion); doubleLongBytesUnion.b1 = hiddenValue[0]; doubleLongBytesUnion.b2 = hiddenValue[1]; doubleLongBytesUnion.b3 = hiddenValue[2]; doubleLongBytesUnion.b4 = hiddenValue[3]; doubleLongBytesUnion.b5 = hiddenValue[4]; doubleLongBytesUnion.b6 = hiddenValue[5]; doubleLongBytesUnion.b7 = hiddenValue[6]; doubleLongBytesUnion.b8 = hiddenValue[7]; return(doubleLongBytesUnion.l); }
private double InternalDecrypt() { if (!inited) { currentCryptoKey = cryptoKey; hiddenValue = InternalEncrypt(0); inited = true; return(0); } var union = new DoubleLongBytesUnion(); union.b8 = hiddenValue; union.l = union.l ^ currentCryptoKey; var decrypted = union.d; return(decrypted); }
public void SetEncrypted(long encrypted) { DoubleLongBytesUnion doubleLongBytesUnion = default(DoubleLongBytesUnion); doubleLongBytesUnion.l = encrypted; hiddenValue = new byte[8] { doubleLongBytesUnion.b1, doubleLongBytesUnion.b2, doubleLongBytesUnion.b3, doubleLongBytesUnion.b4, doubleLongBytesUnion.b5, doubleLongBytesUnion.b6, doubleLongBytesUnion.b7, doubleLongBytesUnion.b8 }; if (onCheatingDetected != null) { fakeValue = InternalDecrypt(); } }
private static void InternalEncrypt(byte[] bytes, double value, long key = 0) { if (key == 0) { key = cryptoKey; } var u = new DoubleLongBytesUnion(); u.d = value; u.l = u.l ^ key; bytes[0] = u.b1; bytes[1] = u.b2; bytes[2] = u.b3; bytes[3] = u.b4; bytes[4] = u.b5; bytes[5] = u.b6; bytes[6] = u.b7; bytes[7] = u.b8; }
public long GetEncrypted() { if (currentCryptoKey != cryptoKey) { double temp = InternalDecrypt(); InternalEncrypt(hiddenValue, temp, cryptoKey); currentCryptoKey = cryptoKey; } var union = new DoubleLongBytesUnion(); union.b1 = hiddenValue[0]; union.b2 = hiddenValue[1]; union.b3 = hiddenValue[2]; union.b4 = hiddenValue[3]; union.b5 = hiddenValue[4]; union.b6 = hiddenValue[5]; union.b7 = hiddenValue[6]; union.b8 = hiddenValue[7]; return(union.l); }
private static byte[] InternalEncrypt(double value, long key) { long num = key; if (num == 0L) { num = cryptoKey; } DoubleLongBytesUnion doubleLongBytesUnion = default(DoubleLongBytesUnion); doubleLongBytesUnion.d = value; doubleLongBytesUnion.l ^= num; return(new byte[8] { doubleLongBytesUnion.b1, doubleLongBytesUnion.b2, doubleLongBytesUnion.b3, doubleLongBytesUnion.b4, doubleLongBytesUnion.b5, doubleLongBytesUnion.b6, doubleLongBytesUnion.b7, doubleLongBytesUnion.b8 }); }
private double InternalDecrypt() { long key = cryptoKey; if (currentCryptoKey != cryptoKey) { key = currentCryptoKey; } var union = new DoubleLongBytesUnion(); union.b1 = hiddenValue[0]; union.b2 = hiddenValue[1]; union.b3 = hiddenValue[2]; union.b4 = hiddenValue[3]; union.b5 = hiddenValue[4]; union.b6 = hiddenValue[5]; union.b7 = hiddenValue[6]; union.b8 = hiddenValue[7]; union.l = union.l ^ key; return(union.d); }
/// <summary> /// Decrypts passed value you got from Encrypt() using same key. /// </summary> /// \sa Encrypt() public static double Decrypt(long value, long key) { return(DoubleLongBytesUnion.XorLongToDouble(value, key)); }