Change Encryption settings after game released

Discussion and help for Easy Save 3
Post Reply
User avatar
fanaei
Posts: 26
Joined: Thu Aug 23, 2018 7:54 am

Change Encryption settings after game released

Post by fanaei »

Hi Joel,
I released my game without encryption on my save files.
Now I wanted to know that is it possible to add password after my game released? Can users still load their previous saves? And if not, is there any solution for adding password?
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Change Encryption settings after game released

Post by Joel »

Hi there,

To do this you would need to convert the files from unencrypted to encrypted when your app first loads. The easiest way to do this would be to access the file with encrypted settings inside a try/catch block. If you catch an exception, use ES3.LoadRawString to load the file with unencrypted settings, and then use ES3.SaveRaw with encrypted settings to save it back to file with encryption.

Something along the lines of:
var unencryptedSettings = new ES3Settings(ES3.EncryptionType.None, "");
var encryptedSettings = new ES3Settings(ES3.EncryptionType.AES, "myPassword");

try
{
    ES3.KeyExists("key", "SaveFile.es3", encryptedSettings);
}
catch(System.Security.Cryptography.CryptographicException)
{
    var unencryptedData = ES3.LoadRawString("SaveFile.es3", unencryptedSettings);
    ES3.SaveRaw(unencryptedData, "SaveFile.es3", encryptedSettings);
}
All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Post Reply