Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.IO;
- using System.Security.Cryptography;
- using UnityEngine;
- public class FileIntegrityChecker : MonoBehaviour
- {
- // Pre-calculated hashes of original game files
- private string originalFileHash = "your_precomputed_hash_here";
- void Start()
- {
- // Path to the file you want to check (e.g., a critical config or data file)
- string filePath = Application.dataPath + "/YourImportantFile.txt";
- // Check if the file's hash matches the original hash
- if (!CheckFileIntegrity(filePath))
- {
- Debug.LogError("File integrity check failed! Exiting game.");
- Application.Quit(); // Optionally exit the game or take action
- }
- else
- {
- Debug.Log("File integrity verified.");
- }
- }
- bool CheckFileIntegrity(string filePath)
- {
- // Generate the SHA-256 hash of the file
- try
- {
- using (SHA256 sha256 = SHA256.Create())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement