Crypter class handles encryption and decryption of Phasmophobia save files using AES-CBC encryption with PBKDF2 key derivation.
Namespace
Methods
Decrypt()
Decrypts an encrypted Phasmophobia save file and returns formatted JSON.The encrypted save file data as a byte array. Must include the 16-byte IV prefix.
string - The decrypted JSON data formatted with indentation, or an error message if decryption fails.
Algorithm Details:
- Extracts the first 16 bytes as the Initialization Vector (IV)
- Uses PBKDF2 (RFC 2898) with SHA1 hash algorithm
- Derives a 16-byte AES key using 100 iterations
- Secret key:
"t36gref9u84y7f43g"(fromGlobals.Save_Secret) - Decrypts using AES-CBC mode with PKCS7 padding
- Parses and formats the resulting JSON
- Returns
"Error: Data is null or empty."if input is null or empty - Returns
"check the correctness of the file: {exception}"if JSON parsing fails
The method automatically formats the decrypted JSON with indentation for readability.
EncryptData()
Encrypts JSON data for use as a Phasmophobia save file.The JSON string to encrypt (typically modified save file data).
byte[] - The encrypted data with the IV prepended as the first 16 bytes.
Algorithm Details:
- Generates a random 16-byte Initialization Vector (IV) using
RandomNumberGenerator - Uses PBKDF2 (RFC 2898) with SHA1 hash algorithm
- Derives a 16-byte AES key using 100 iterations
- Secret key:
"t36gref9u84y7f43g"(fromGlobals.Save_Secret) - Encrypts using AES-CBC mode with PKCS7 padding
- Prepends the IV to the encrypted data
Encryption Implementation
Key Derivation
Both methods use PBKDF2 for key derivation:AES Configuration
Dependencies
System.Security.Cryptography- For AES and PBKDF2Newtonsoft.Json- For JSON parsing and formattingPhasmoDecrypt.Globals- For the encryption secret key
Source Reference
See the full implementation:/workspace/source/Classes/Crypter.cs:14-86