Skip to main content
Namespace: Molca.Networking.Utils
File: Packages/com.molca.core/Runtime/Networking/Utils/Encryption.cs
Type: RuntimeSubsystem (child of RuntimeManager prefab)

When to use

Use Encryption for local at-rest obfuscation of cache data written by CacheManager. For sensitive credentials, use SecureStorage instead.
⚠️ This is at-rest obfuscation, not strong cryptography. The AES key is derived from the configured public-key asset (or deviceUniqueIdentifier as fallback) — both are non-secret material available to the running app.

Role

  • Local AES-256-CBC encryptionEncryptData/DecryptData encrypt/decrypt byte arrays for cache file storage. IV is randomly generated per operation and prepended to the output.
  • Key derivation — uses SHA-256 of the configured PEM public key (extracted from -----BEGIN PUBLIC KEY----- markers) or, if absent, SystemInfo.deviceUniqueIdentifier.
  • Public-key string flow removedEncryptString/DecryptString are [Obsolete] and throw NotSupportedException. This flow was removed in Sprint 4.6 because it relied on RSA decryption with a public key, which is cryptographically impossible.

Inspector configuration

API Reference

Code

Troubleshooting

  • EncryptString/DecryptString throw NotSupportedException: these methods were removed. Use EncryptData/DecryptData for byte-level encryption, or SecureStorage for credentials.
  • Different device, different key: without a configured _publicKey TextAsset, the key derives from deviceUniqueIdentifier, meaning cache files are not portable across devices.
  • CacheManager — consumes Encryption for cache file obfuscation
  • SecureStorage — encrypted storage for credentials (preferred for sensitive data)
  • RuntimeManagerEncryption is a child subsystem