Anti-Cheat Toolkit  2023.2.6
Multi-purpose anti-cheat solution for Unity Engine
ObscuredDouble Struct Reference

Inherits IFormattable, IEquatable< ObscuredDouble >, IEquatable< double >, IComparable< ObscuredDouble >, IComparable< double >, IComparable, and IObscuredType.

Public Member Functions

long GetEncrypted (out long key)
void SetEncrypted (long encrypted, long key)
double GetDecrypted ()
void RandomizeCryptoKey ()

Static Public Member Functions

static long Encrypt (double value, long key)
static double Decrypt (long value, long key)
static long MigrateEncrypted (long encrypted, byte fromVersion=0, byte toVersion=2)
static ObscuredDouble FromEncrypted (long encrypted, long key)
static long GenerateKey ()

Detailed Description

Use it instead of regular double for any cheating-sensitive variables.

Regular type is faster and memory wiser comparing to the obscured one!
Feel free to use regular types for all short-term operations and calculations while keeping obscured type only at the long-term declaration (i.e. class field).

Member Function Documentation

◆ Encrypt()

static long Encrypt ( double  value,
long  key 

Encrypts passed value using passed key.

Key can be generated automatically using GenerateKey().

See also
Decrypt(), GenerateKey()

◆ Decrypt()

static double Decrypt ( long  value,
long  key 

Decrypts passed value you got from Encrypt() using same key.

See also

◆ MigrateEncrypted()

static long MigrateEncrypted ( long  encrypted,
byte  fromVersion = 0,
byte  toVersion = 2 

Allows to update the encrypted value to the newer encryption format.

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 to the format

encryptedEncrypted value you got from previous ACTk version obscured type with GetEncrypted().
fromVersionSource format version.
toVersionTarget format version.
Migrated raw encrypted value which you may use for SetEncrypted() later.

◆ FromEncrypted()

static ObscuredDouble FromEncrypted ( long  encrypted,
long  key 

Creates and fills obscured variable with raw encrypted value previously got from GetEncrypted().

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.

encryptedRaw encrypted value you got from GetEncrypted().
keyEncryption key you've got from GetEncrypted().
New obscured variable initialized from specified encrypted value.
See also
GetEncrypted(), SetEncrypted()

◆ GenerateKey()

static long GenerateKey ( )

Generates random key. Used internally and can be used to generate key for manual Encrypt() calls.

Key suitable for manual Encrypt() calls.

◆ GetEncrypted()

long GetEncrypted ( out long  key)

Allows to pick current obscured value as is.

keyEncryption key needed to decrypt returned value.
Encrypted value as is.

Use it in conjunction with SetEncrypted().
Useful for saving data in obscured state.

See also
FromEncrypted(), SetEncrypted()

◆ SetEncrypted()

void SetEncrypted ( long  encrypted,
long  key 

Allows to explicitly set current obscured value. Crypto key should be same as when encrypted value was got with GetEncrypted().

Use it in conjunction with GetEncrypted().
Useful for loading data stored in obscured state.

See also

◆ GetDecrypted()

double GetDecrypted ( )

Alternative to the type cast, use if you wish to get decrypted value but can't or don't want to use cast to the regular type.

Decrypted value.

◆ RandomizeCryptoKey()

void RandomizeCryptoKey ( )

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.

Implements IObscuredType.