Anti-Cheat Toolkit  2023.2.6
Multi-purpose anti-cheat solution for Unity Engine
CodeStage.AntiCheat.Storage Namespace Reference

Classes

class  DeviceIdHolder
 
class  DeviceLockSettings
 
class  ObscuredFile
 
struct  ObscuredFileError
 
struct  ObscuredFileReadResult
 
struct  ObscuredFileWriteResult
 
class  ObscuredFilePrefs
 
class  EncryptionSettings
 
interface  IObscuredFileSettings
 
class  ObscuredFileSettings
 
class  ObscuredPrefs
 

Enumerations

enum class  StorageDataType : byte {
  Unknown = 0 , SByte = 1 , Byte = 2 , Int16 = 3 ,
  UInt16 = 4 , Int32 = 5 , UInt32 = 10 , Int64 = 30 ,
  UInt64 = 32 , Char = 33 , Single = 20 , Double = 25 ,
  Decimal = 27 , BigInteger = 28 , Boolean = 35 , String = 15 ,
  DateTime = 37 , ByteArray = 40 , Vector2 = 45 , Vector2Int = 47 ,
  Vector3 = 50 , Vector3Int = 51 , Vector4 = 53 , Quaternion = 55 ,
  Color = 60 , Color32 = 62 , Rect = 65 , RectInt = 67 ,
  RangeInt = 70 , Matrix4x4 = 78 , Ray = 80 , Ray2D = 83
}
 
enum class  DeviceLockLevel : byte { None , Soft , Strict }
 
enum class  DeviceLockTamperingSensitivity : byte { Disabled , Low , Normal }
 
enum class  ObscuredFileErrorCode : byte {
  NoError = 0 , FileNotFound = 5 , FileDamaged = 10 , DataIsNotLocked = 15 ,
  NotInitialized = 20 , OtherException = 250
}
 
enum class  ObscurationMode : byte { Plain = 0 , Encrypted = 1 }
 
enum class  ObscuredFileLocation : byte { PersistentData = 5 , Custom = 10 }
 

Enumeration Type Documentation

◆ StorageDataType

enum StorageDataType : byte
strong

Data types supported by ObscuredPrefs and ObscuredFilePrefs.

Enumerator
Unknown 

Reserved for unsupported types.

SByte 

System.SByte

Byte 

System.Byte

Int16 

System.Int16

UInt16 

System.UInt16

Int32 

System.Int32

UInt32 

System.UInt32

Int64 

System.Int64

UInt64 

System.UInt64

Char 

System.Char

Single 

System.Single

Double 

System.Double

Decimal 

System.Decimal

BigInteger 

System.BigInteger

Boolean 

System.Boolean

String 

System.String

DateTime 

System.DateTime

ByteArray 

Array of System.Byte

Vector2 

UnityEngine.Vector2

Vector2Int 

UnityEngine.Vector2Int

Vector3 

UnityEngine.Vector3

Vector3Int 

UnityEngine.Vector3Int

Vector4 

UnityEngine.Vector4

Quaternion 

UnityEngine.Quaternion

Color 

UnityEngine.Color

Color32 

UnityEngine.Color32

Rect 

UnityEngine.Rect

RectInt 

UnityEngine.RectInt

RangeInt 

UnityEngine.RangeInt

Matrix4x4 

UnityEngine.Matrix4x4

Ray 

UnityEngine.Ray

Ray2D 

UnityEngine.Ray2D

◆ DeviceLockLevel

enum DeviceLockLevel : byte
strong

Used to specify level of the device lock feature strictness.

Use it to prevent cheating via 100% game saves sharing or sharing purchased in-app items for example.

Relies on SystemInfo.deviceUniqueIdentifier when not using custom DeviceIdHolder.DeviceId.
Please note, deviceUniqueIdentifier may change in some rare cases, so one day all locked data may became inaccessible on same device.

WARNING: On iOS use at your peril with default DeviceId! There is no reliable way to get persistent device ID on iOS. So avoid using it or use in conjunction with DeviceIdHolder.DeviceId (see below).
NOTE #1: On iOS it tries to receive vendorIdentifier in first place, to avoid device id change while updating from iOS6 to iOS7. It leads to device ID change while updating from iOS5, but such case appears much rarer.
NOTE #2: You may use own device id via DeviceIdHolder.DeviceId property to make it more reliable and predictable. Use it to lock saves to the specified email for example.
NOTE #3: Main thread may lock up for a noticeable time while obtaining device ID first time on some devices. Consider using DeviceIdHolder.ForceLockToDeviceInit() at loading screen or other desirable stall moment of your app to prevent undesirable behavior in such cases.

See also
DeviceIdHolder.ForceLockToDeviceInit(), DeviceIdHolder.DeviceId, ObscuredPrefs.DeviceLockSettings, ObscuredFilePrefs.DeviceLockSettings, DeviceLockSettings
Enumerator
None 

Both locked and not locked to any device data can be read and does not locks saves to the current device.

Soft 

Does locks to the current device and still allows reading not locked data (useful when you decided to lock your saves in one of app updates and wish to keep user data).

Strict 

Does locks to the current device and reads only locked to the current device data. This is a preferred mode, but it should be enabled right from the first app release. If you released an app without data lock consider using Soft lock or any previously saved data will not be accessible.

◆ DeviceLockTamperingSensitivity

enum DeviceLockTamperingSensitivity : byte
strong

Controls device lock tampering sensitivity - from fully functional to full tampering ignorance. Emits DataFromAnotherDeviceDetected event when detecting data from another device.

See also
DeviceLockLevel, ObscuredFile.DataFromAnotherDeviceDetected, ObscuredFilePrefs.DataFromAnotherDeviceDetected, ObscuredPrefs.DataFromAnotherDeviceDetected
Enumerator
Disabled 

Allows reading data from another devices without detection.

Low 

Allows reading data from another devices and emits DataFromAnotherDeviceDetected event.

Normal 

Prevents reading data from another device and emits DataFromAnotherDeviceDetected event.

◆ ObscuredFileErrorCode

enum ObscuredFileErrorCode : byte
strong

Possible error codes for the file read operation.

Enumerator
NoError 

Indicates no errors happened.

FileNotFound 

Indicates file to read from wasn't found.

FileDamaged 

Indicates file header was damaged.

DataIsNotLocked 

Indicates read data was not locked but you are using DeviceLockLevel.Strict which prevents reading such files.

NotInitialized 

Indicates used tool wasn't properly initialized. See error logs for more information.

OtherException 

Indicates some other exception occured, see ObscuredFileError.Exception for details.

◆ ObscurationMode

enum ObscurationMode : byte
strong

Represents how data will be saved to file.

Enumerator
Plain 

No encryption, just plain binary data. Serialized data will be readable.

Encrypted 

All data will be encrypted and not readable in the file.

◆ ObscuredFileLocation

enum ObscuredFileLocation : byte
strong

Specifies file location.

Enumerator
PersistentData 

Corresponds to the Application.persistentDataPath.

Custom 

Allows setting custom file path.