Advertisement
DOGGYWOOF

Regeistered hash

Jan 27th, 2024
4
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. -- Function to calculate MD5 hash
  2. function calculateMD5(content)
  3. -- Use the md5 library or implementation of your choice
  4. -- Example: https://github.com/kikito/md5.lua
  5. local md5 = require("md5")
  6. return md5.sumhexa(content)
  7. end
  8.  
  9. -- Function to check if a disk is registered
  10. function isDiskRegistered()
  11. local diskLabel = os.getComputerLabel() or "UnknownDisk"
  12.  
  13. -- Check if registered.txt exists
  14. if fs.exists("/"..diskLabel.."/registered.txt") then
  15. local file = fs.open("/"..diskLabel.."/registered.txt", "r")
  16. local content = file.readAll()
  17. file.close()
  18.  
  19. -- Replace the hash value with the correct one
  20. local correctHash = "0f341991f07ba45cef793234f651bf24"
  21.  
  22. -- Check if the hash matches
  23. if calculateMD5(content) == correctHash then
  24. return true
  25. else
  26. print("ERROR: Invalid hash in registered.txt")
  27. end
  28. else
  29. print("ERROR: registered.txt not found")
  30. end
  31.  
  32. return false
  33. end
  34.  
  35. -- Main program
  36. if isDiskRegistered() then
  37. print("Disk is registered. Running allowed.")
  38. -- Your main code goes here
  39. else
  40. print("Disk is not registered. Running blocked.")
  41. end
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement