Encryption Extensions
Encrypt
This line calls the Encrypt extension method to encrypt the string sensitiveData. The resulting encrypted string is logged for debugging purposes.
string sensitiveData = "PlayerPassword: secret123";
string encryptedData = EncryptExtensions.Encrypt(sensitiveData);
Debug.Log("Encrypted Data: " + encryptedData);
Encrypt with Custom Key
This example shows how to encrypt data using a custom encryption key. The resulting encrypted string is logged for debugging.
string sensitiveData = "PlayerPassword: secret123";
string encryptedData = EncryptExtensions.Encrypt(sensitiveData, "YOUR_CUSTOM_KEY");
Debug.Log("Encrypted Data with Custom Key: " + encryptedData);
Decrypt
This line calls the Decrypt extension method to decrypt the previously encrypted string. The result, which should match the original sensitive data, is logged for verification.
string decryptedData = EncryptExtensions.Decrypt(encryptedData);
Debug.Log("Decrypted Data: " + decryptedData);
Decrypt with Custom Key
This demonstrates how to decrypt data that was encrypted with a custom key, ensuring that the same key is used for successful decryption. The decrypted result is logged for verification.
string decryptedData = EncryptExtensions.Decrypt(encryptedData, "YOUR_CUSTOM_KEY");
Debug.Log("Decrypted Data with Custom Key: " + decryptedData);
Last updated