Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Function to generate a hash from the computer ID
- local function generateHash(id)
- -- A simple reversible hash function
- return (id * 12345 + 67890) % 1000000
- end
- -- Retrieve the current computer ID
- local computerID = os.getComputerID()
- -- Generate a hash from the computer ID
- local hashedID = generateHash(computerID)
- -- Create a table for the configuration data
- local config = {
- Hardware = {
- HashedID = hashedID
- }
- }
- -- Function to create and write the config file in a JSON-like format
- local function createConfigFile(config)
- local file = fs.open("HardwareID.cfg", "w")
- -- Convert table to JSON-like format
- local jsonContent = "{\n"
- jsonContent = jsonContent .. ' "Hardware": {\n'
- jsonContent = jsonContent .. ' "HashedID": ' .. config.Hardware.HashedID .. '\n'
- jsonContent = jsonContent .. ' }\n'
- jsonContent = jsonContent .. '}\n'
- file.write(jsonContent)
- file.close()
- print("Configuration file 'HardwareID.cfg' created successfully.")
- end
- -- Create the config file with the hashed ID
- createConfigFile(config)
- print("Setup completed. Your computer is now registered.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement