Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Function to draw a border
- local function drawBorder()
- term.clear()
- local w, h = term.getSize()
- for y = 1, h do
- term.setCursorPos(1, y)
- term.write("|")
- term.setCursorPos(w, y)
- term.write("|")
- end
- for x = 1, w do
- term.setCursorPos(x, 1)
- term.write("-")
- term.setCursorPos(x, h)
- term.write("-")
- end
- term.setCursorPos(1, 1)
- term.write("+")
- term.setCursorPos(w, 1)
- term.write("+")
- term.setCursorPos(1, h)
- term.write("+")
- term.setCursorPos(w, h)
- term.write("+")
- end
- -- Function to center text on the screen
- local function centerText(text, y)
- local w, _ = term.getSize()
- local x = math.floor((w - #text) / 2) + 1
- term.setCursorPos(x, y)
- term.write(text)
- end
- -- Function to verify the recovery key
- local function verifyRecoveryKey()
- local keyPath = "/disk/security/RecoveryKey.txt"
- if fs.exists(keyPath) then
- local file = fs.open(keyPath, "r")
- local storedKey = file.readAll()
- file.close()
- term.clear()
- drawBorder()
- centerText("Enter Recovery Key", 3)
- term.setCursorPos(5, 5)
- term.write("Recovery Key: ")
- local enteredKey = read()
- if enteredKey == storedKey then
- centerText("Recovery successful. Welcome!", 8)
- os.sleep(2)
- return true
- else
- centerText("Invalid Recovery Key. Access denied.", 8)
- os.sleep(2)
- end
- else
- centerText("Recovery Key not found. Access denied.", 8)
- os.sleep(2)
- end
- return false
- end
- -- Function to start recovery key authentication
- local function authenticate()
- term.clear()
- drawBorder()
- centerText("Doggy OS Recovery key", 3)
- if not verifyRecoveryKey() then
- os.reboot()
- end
- end
- -- Start authentication process
- authenticate()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement