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

Inherits IFormattable, IEquatable< ObscuredDateTimeOffset >, IEquatable< DateTimeOffset >, IComparable< ObscuredDateTimeOffset >, IComparable< DateTimeOffset >, IComparable, IObscuredType, ISerializableObscuredType, and ISerializationCallbackReceiver.

Public Member Functions

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

Static Public Member Functions

static long Encrypt (DateTimeOffset value, long key)
 
static DateTimeOffset Decrypt (long value, long key)
 
static ObscuredDateTimeOffset FromEncrypted (long encrypted, long key)
 
static long GenerateKey ()
 

Properties

long Ticks [get]
 
DateTime Date [get]
 
DateTime DateTime [get]
 
int Day [get]
 
DayOfWeek DayOfWeek [get]
 
int DayOfYear [get]
 
int Hour [get]
 
int Millisecond [get]
 
int Minute [get]
 
int Month [get]
 
TimeSpan Offset [get]
 
int Second [get]
 
TimeSpan TimeOfDay [get]
 
DateTime UtcDateTime [get]
 
int Year [get]
 

Detailed Description

Use it instead of regular DateTimeOffset 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 long Encrypt ( DateTimeOffset  value,
long  key 
)
inlinestatic

Encrypts passed value using passed key.

Key can be generated automatically using GenerateKey().

See also
Decrypt(), GenerateKey()

◆ Decrypt()

static DateTimeOffset Decrypt ( long  value,
long  key 
)
inlinestatic

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

See also
Encrypt()

◆ FromEncrypted()

static ObscuredDateTimeOffset FromEncrypted ( long  encrypted,
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
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 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()

long GetEncrypted ( out long  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 ( long  encrypted,
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()

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

Property Documentation

◆ Ticks

long Ticks
get

Gets the number of ticks that represent the date and time of this instance.

Returns
The number of ticks that represent the date and time of this instance. The value is between DateTimeOffset.MinValue.Ticks and DateTimeOffset.MaxValue.Ticks.

◆ Date

DateTime Date
get

Gets the date component of this instance.

Returns
A new object with the same date as this instance, and the time value set to 12:00:00 midnight (00:00:00).

◆ DateTime

DateTime DateTime
get

Gets the date and time represented by this instance.

Returns
The date and time represented by this instance.

◆ Day

int Day
get

Gets the day of the month represented by this instance.

Returns
The day component, expressed as a value between 1 and 31.

◆ DayOfWeek

DayOfWeek DayOfWeek
get

Gets the day of the week represented by this instance.

Returns
An enumerated constant that indicates the day of the week of this DateTimeOffset value.

◆ DayOfYear

int DayOfYear
get

Gets the day of the year represented by this instance.

Returns
The day of the year, expressed as a value between 1 and 366.

◆ Hour

int Hour
get

Gets the hour component of the time represented by this instance.

Returns
The hour component, expressed as a value between 0 and 23.

◆ Millisecond

int Millisecond
get

Gets the millisecond component of the time represented by this instance.

Returns
The millisecond component, expressed as a value between 0 and 999.

◆ Minute

int Minute
get

Gets the minute component of the time represented by this instance.

Returns
The minute component, expressed as a value between 0 and 59.

◆ Month

int Month
get

Gets the month component of the date represented by this instance.

Returns
The month component, expressed as a value between 1 and 12.

◆ Offset

TimeSpan Offset
get

Gets the time's offset from Coordinated Universal Time (UTC).

Returns
The time's offset from Coordinated Universal Time (UTC).

◆ Second

int Second
get

Gets the second component of the clock time represented by this instance.

Returns
The second component, expressed as a value between 0 and 59.

◆ TimeOfDay

TimeSpan TimeOfDay
get

Gets the time of day for this instance.

Returns
A time interval that represents the fraction of the day that has elapsed since midnight.

◆ UtcDateTime

DateTime UtcDateTime
get

Gets a DateTime value that represents the Coordinated Universal Time (UTC) date and time equivalent to the current DateTimeOffset object.

Returns
A value that represents the UTC equivalent of the current DateTimeOffset object.

◆ Year

int Year
get

Gets the year component of the date represented by this instance.

Returns
The year, between 1 and 9999.