Advertisement
MR_Spagetty

Password.lua

Jan 19th, 2021 (edited)
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.86 KB | None | 0 0
  1. require("process").info().data.signal = function()end -- Blocking Ctrl+Alt+C
  2. local event = require('event')
  3. local term = require('term')
  4. local gpu = require('component').gpu
  5. local W, H = gpu.getResolution()
  6. local color1, color2 = 0x00FF00, 0xFF0000
  7. local password = '123456789' -- needed hash function, for most security
  8.  
  9. event.shouldSoftInterrupt = function() return false end -- blocking Ctrl+C
  10.  
  11. gpu.setForeground(color1)
  12. while true do
  13.   term.clear()
  14.   term.setCursor(W/2-10, H/2)
  15.   term.write('PASSWORD: ')
  16.   local input = tostring(term.read(_,_,_,'*')):sub(1, -2)
  17.     if input == password then
  18.     term.clear()
  19.     term.setCursor(1, 1)
  20.     gpu.setForeground(0xFFFFFF)
  21.     os.exit()
  22. else
  23.     term.clear()
  24.     gpu.setForeground(color2)
  25.     term.setCursor(W/2-6, H/2)
  26.     term.write('ACCESS DENIED')
  27.     gpu.setForeground(color1)
  28.     os.sleep(3)
  29. end
  30. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement