-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement a hash to check for tempered files
- Loading branch information
1 parent
ac9fdc3
commit 80e2d0f
Showing
7 changed files
with
89 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
FairyTaleDefender/Assets/_Game/Scripts/Runtime/Systems/SaveGameSystem/SaveGameHash.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System.IO; | ||
using System.Security.Cryptography; | ||
using UnityEngine; | ||
|
||
namespace BoundfoxStudios.FairyTaleDefender.Systems.SaveGameSystem | ||
{ | ||
public static class SaveGameHash | ||
{ | ||
public static string Create(string saveName, string saveGameFilePath) | ||
{ | ||
using var sha512 = SHA512.Create(); | ||
using var fileStream = new FileStream(saveGameFilePath, FileMode.Open, FileAccess.Read); | ||
var fileHash = sha512.ComputeHash(fileStream); | ||
|
||
var hash = new Hash128(); | ||
|
||
hash.Append(saveName); | ||
hash.Append(fileHash); | ||
|
||
return hash.ToString(); | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
FairyTaleDefender/Assets/_Game/Scripts/Runtime/Systems/SaveGameSystem/SaveGameHash.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters