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

Inherits IEquatable< ObscuredVector3 >, IEquatable< Vector3 >, and IObscuredType.

Classes

struct  RawEncryptedVector3
 

Public Member Functions

 ObscuredVector3 (float x, float y, float z)
 
RawEncryptedVector3 GetEncrypted (out int key)
 
void SetEncrypted (RawEncryptedVector3 encrypted, int key)
 
Vector3 GetDecrypted ()
 
void RandomizeCryptoKey ()
 

Static Public Member Functions

static RawEncryptedVector3 Encrypt (Vector3 value, int key)
 
static RawEncryptedVector3 Encrypt (float x, float y, float z, int key)
 
static Vector3 Decrypt (RawEncryptedVector3 value, int key)
 
static ObscuredVector3 FromEncrypted (RawEncryptedVector3 encrypted, int key)
 
static int GenerateKey ()
 

Detailed Description

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

WARNING: Doesn't mimic regular type API, thus should be used with extra caution. Cast it to regular, not obscured type to work with regular APIs.
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).

Constructor & Destructor Documentation

◆ ObscuredVector3()

ObscuredVector3 ( float  x,
float  y,
float  z 
)
inline

Mimics constructor of regular Vector3.

Parameters
xX component of the vector
yY component of the vector
zZ component of the vector

Member Function Documentation

◆ Encrypt() [1/2]

static RawEncryptedVector3 Encrypt ( Vector3  value,
int  key 
)
inlinestatic

Encrypts passed value using passed key.

Key can be generated automatically using GenerateKey().

See also
Decrypt(), GenerateKey()

◆ Encrypt() [2/2]

static RawEncryptedVector3 Encrypt ( float  x,
float  y,
float  z,
int  key 
)
inlinestatic

Encrypts passed components using passed key.

Key can be generated automatically using GenerateKey().

See also
Decrypt(), GenerateKey()

◆ Decrypt()

static Vector3 Decrypt ( RawEncryptedVector3  value,
int  key 
)
inlinestatic

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

See also
Encrypt()

◆ FromEncrypted()

static ObscuredVector3 FromEncrypted ( RawEncryptedVector3  encrypted,
int  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
encryptedRaw 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 int 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()

RawEncryptedVector3 GetEncrypted ( out int  key)
inline

Allows to pick current obscured value as is.

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

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

See also
FromEncrypted(), SetEncrypted()

◆ SetEncrypted()

void SetEncrypted ( RawEncryptedVector3  encrypted,
int  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()

Vector3 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.