Advertisement
Hygcgggnngff

anti cheat paid Anti ban evade 2

Sep 28th, 2024 (edited)
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.13 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityEngine.Networking;
  3. using System.Collections;
  4. using System.IO;
  5. using System.Security.Cryptography;
  6.  
  7. public class ServerFileValidation : MonoBehaviour
  8. {
  9.     private string serverURL = "https://yourserver.com/validateFile";
  10.  
  11.     void Start()
  12.     {
  13.         string filePath = Application.dataPath + "/YourImportantFile.txt";
  14.         StartCoroutine(ValidateFileWithServer(filePath));
  15.     }
  16.  
  17.     IEnumerator ValidateFileWithServer(string filePath)
  18.     {
  19.         // Compute the file's SHA-256 hash
  20.         string fileHash = ComputeFileHash(filePath);
  21.  
  22.         if (fileHash != null)
  23.         {
  24.             // Send the file hash to the server for validation
  25.             UnityWebRequest www = UnityWebRequest.Get(serverURL + "?fileHash=" + fileHash);
  26.             yield return www.SendWebRequest();
  27.  
  28.             if (www.isNetworkError || www.isHttpError)
  29.             {
  30.                 Debug.LogError("Error connecting to server: " + www.error);
  31.             }
  32.             else
  33.             {
  34.                 // Process the server's response
  35.                 if (www.downloadHandler.text != "OK")
  36.                 {
  37.                     Debug.LogError("File validation failed. Exiting game.");
  38.                     Application.Quit();
  39.                 }
  40.                 else
  41.                 {
  42.                     Debug.Log("File validation successful.");
  43.                 }
  44.             }
  45.         }
  46.     }
  47.  
  48.     string ComputeFileHash(string filePath)
  49.     {
  50.         try
  51.         {
  52.             using (SHA256 sha256 = SHA256.Create())
  53.             {
  54.                 using (FileStream fileStream = File.OpenRead(filePath))
  55.                 {
  56.                     byte[] fileHash = sha256.ComputeHash(fileStream);
  57.                     return ByteArrayToString(fileHash);
  58.                 }
  59.             }
  60.         }
  61.         catch (System.Exception e)
  62.         {
  63.             Debug.LogError("Error computing file hash: " + e.Message);
  64.             return null;
  65.         }
  66.     }
  67.  
  68.     string ByteArrayToString(byte[] byteArray)
  69.     {
  70.         return System.BitConverter.ToString(byteArray).Replace("-", "").ToLower();
  71.     }
  72. }
  73.  
Tags: Anti
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement