Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encrypt saves, update encryption strategy #76

Merged
merged 2 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Packages/com.trytalo.talo/Runtime/APIs/SavesAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class SavesAPI : BaseAPI
public event Action<GameSave> OnSaveChosen;
public event Action OnSaveLoadingCompleted;

private readonly string _offlineSavesPath = Application.persistentDataPath + "/talo-saves.bin";
private readonly string _offlineSavesPath = Application.persistentDataPath + "/ts.bin";
private IFileHandler<OfflineSavesContent> _fileHandler;

public GameSave[] All
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class ContinuityContent

public class ContinuityManager
{
private readonly string _continuityPath = Application.persistentDataPath + "/talo-continuity.bin";
private readonly string _continuityPath = Application.persistentDataPath + "/tc.bin";

private List<Request> _requests;

Expand Down
4 changes: 2 additions & 2 deletions Packages/com.trytalo.talo/Runtime/Utils/CryptoManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace TaloGameServices
{
public class CryptoManager
{
private readonly string _keyPath = Application.persistentDataPath + "/talo-init.bin";
private readonly string _keyPath = Application.persistentDataPath + "/ti.bin";

private IFileHandler<string> _fileHandler;

Expand Down Expand Up @@ -52,7 +52,7 @@ private byte[] GetAESKey()
{
using (var sha256 = SHA256.Create())
{
return sha256.ComputeHash(Encoding.UTF8.GetBytes(Talo.Settings.accessKey));
return sha256.ComputeHash(Encoding.UTF8.GetBytes(SystemInfo.deviceUniqueIdentifier));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ public class SavesFileHandler : IFileHandler<OfflineSavesContent>
public OfflineSavesContent ReadContent(string path)
{
if (!File.Exists(path)) return null;
return JsonUtility.FromJson<OfflineSavesContent>(File.ReadAllText(path));
return JsonUtility.FromJson<OfflineSavesContent>(Talo.Crypto.ReadFileContent(path));
}

public void WriteContent(string path, OfflineSavesContent content)
{
File.WriteAllText(path, JsonUtility.ToJson(content));
Talo.Crypto.WriteFileContent(path, JsonUtility.ToJson(content));
}
}