Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local cipher = {
- A = "X",
- B = "Y",
- -- Add more substitutions for each character as needed
- }
- function encryptPassword(password)
- local encrypted = ""
- for i = 1, #password do
- local char = string.upper(string.sub(password, i, i))
- if cipher[char] then
- encrypted = encrypted .. cipher[char]
- else
- encrypted = encrypted .. char
- end
- end
- return encrypted
- end
- function decryptPassword(encrypted)
- local decrypted = ""
- for i = 1, #encrypted do
- local char = string.upper(string.sub(encrypted, i, i))
- local found = false
- for key, value in pairs(cipher) do
- if value == char then
- decrypted = decrypted .. key
- found = true
- break
- end
- end
- if not found then
- decrypted = decrypted .. char
- end
- end
- return decrypted
- end
- local doorSide = "right" -- Side of the door
- function unlockDoor()
- redstone.setOutput(doorSide, true) -- Unlock the door (if it accepts redstone)
- print("Door unlocked on the right side.")
- end
- function lockDoor()
- redstone.setOutput(doorSide, false) -- Lock the door (if it accepts redstone)
- print("Door locked on the right side.")
- end
- -- Usage example
- local password = "MySecretPassword"
- local encryptedPassword = encryptPassword(password)
- print("Encrypted Password:", encryptedPassword)
- -- Assuming the user inputs the correct password
- local userInput = io.read()
- if userInput == encryptedPassword then
- unlockDoor() -- Unlock the door on the right side
- else
- print("Incorrect password.")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement