Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Function to calculate MD5 hash
- function calculateMD5(content)
- -- Use the md5 library or implementation of your choice
- -- Example: https://github.com/kikito/md5.lua
- local md5 = require("md5")
- return md5.sumhexa(content)
- end
- -- Function to check if a disk is registered
- function isDiskRegistered()
- local diskLabel = os.getComputerLabel() or "UnknownDisk"
- -- Check if registered.txt exists
- if fs.exists("/"..diskLabel.."/registered.txt") then
- local file = fs.open("/"..diskLabel.."/registered.txt", "r")
- local content = file.readAll()
- file.close()
- -- Replace the hash value with the correct one
- local correctHash = "0f341991f07ba45cef793234f651bf24"
- -- Check if the hash matches
- if calculateMD5(content) == correctHash then
- return true
- else
- print("ERROR: Invalid hash in registered.txt")
- end
- else
- print("ERROR: registered.txt not found")
- end
- return false
- end
- -- Main program
- if isDiskRegistered() then
- print("Disk is registered. Running allowed.")
- -- Your main code goes here
- else
- print("Disk is not registered. Running blocked.")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement