Anti-Cheat Toolkit  6.1.0
Multi-purpose anti-cheat solution for Unity Engine
ObscuredGuid Struct Reference

Inherits IFormattable, IEquatable< ObscuredGuid >, IEquatable< Guid >, IComparable< ObscuredGuid >, IComparable< Guid >, IComparable, IObscuredType, ISerializableObscuredType, and ISerializationCallbackReceiver.

Public Member Functions

void GetEncrypted (out long key, out long encrypted1, out long encrypted2)
 
void SetEncrypted (long encrypted1, long encrypted2, long key)
 
Guid GetDecrypted ()
 
void RandomizeCryptoKey ()
 

Static Public Member Functions

static void Encrypt (Guid value, long key, out long encrypted1, out long encrypted2)
 
static Guid Decrypt (long encrypted1, long encrypted2, long key)
 
static ObscuredGuid FromEncrypted (long encrypted1, long encrypted2, long key)
 
static long GenerateKey ()
 

Detailed Description

Use it instead of regular Guid for any cheating-sensitive properties, fields and other long-term declarations.

Regular type is faster and memory wiser comparing to the obscured one!
Use regular type 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 void Encrypt ( Guid  value,
long  key,
out long  encrypted1,
out long  encrypted2 
)
inlinestatic

Encrypts passed value using passed key.

Key can be generated automatically using GenerateKey().

See also
Decrypt(), GenerateKey()

◆ Decrypt()

static Guid Decrypt ( long  encrypted1,
long  encrypted2,
long  key 
)
inlinestatic

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

See also
Encrypt()

◆ FromEncrypted()

static ObscuredGuid FromEncrypted ( long  encrypted1,
long  encrypted2,
long  key 
)
inlinestatic

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.

Parameters
encrypted1First part of raw encrypted value you got from GetEncrypted().
encrypted2Second part of raw encrypted value you got from GetEncrypted().
keyEncryption key you've got from GetEncrypted().
Returns
New obscured variable initialized from specified encrypted value.
See also
GetEncrypted(), SetEncrypted()

◆ GenerateKey()

static long GenerateKey ( )
inlinestatic

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

Returns
Key suitable for manual Encrypt() calls.

◆ GetEncrypted()

void GetEncrypted ( out long  key,
out long  encrypted1,
out long  encrypted2 
)
inline

Allows to pick current obscured value as is.

Parameters
keyEncryption key needed to decrypt returned value.
encrypted1First part of encrypted value as is.
encrypted2Second part of 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  encrypted1,
long  encrypted2,
long  key 
)
inline

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
FromEncrypted()

◆ GetDecrypted()

Guid GetDecrypted ( )
inline

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.

Returns
Decrypted value.

◆ RandomizeCryptoKey()

void RandomizeCryptoKey ( )
inline

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.