Advertisement
Guest User

startup

a guest
Apr 28th, 2018
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.68 KB | None | 0 0
  1. local currencyName = "Diamonds"
  2. local chan = 12345
  3. peripheral.find("modem").open(chan)
  4. if not fs.exists("/users") then
  5.   fs.makeDir("/users")
  6. end
  7. if not fs.exists("/balance") then
  8.   fs.makeDir("/balance")
  9. end
  10. if not fs.exists("/sha256") then
  11.   f = fs.open("sha256",'w')
  12.   f.writeLine(http.get('https://raw.github.com/jakemroman/JakeHub/master/sha256').readAll())
  13.   f.close()
  14. end
  15. os.loadAPI("sha256")
  16.   term.current().setVisible(false)
  17.   term.clear()
  18.   term.current().setVisible(true)
  19.   term.setCursorPos(2,2)
  20.   write("QuantumTech Banking")
  21.   term.setCursorPos(2,5)
  22.   write("If you do not have an account then")
  23.   term.setCursorPos(2,6)
  24.   write("enter your credentials now.")
  25.   term.setCursorPos(2,8)
  26.   write("Currency: ")
  27.   term.setTextColor(colors.black)
  28.   write(currencyName)
  29.   term.setCursorPos(2,9)
  30.   write("Username: ")
  31.   local username = read()
  32.   term.setCursorPos(2,11)
  33.   write("Password: ")
  34.   local password = sha256.sha256(read("*"))
  35.   term.setCursorPos(2,4)
  36.   if fs.exists("/users/"..username) then
  37.     f = fs.open("/users/"..username,"r")
  38.     local pw = f.readAll()
  39.     f.close()
  40.     if pw == password then
  41.       term.setTextColor(colors.green)
  42.       write("Access Granted!")
  43.       sleep(1)
  44.       term.clear()
  45.       term.setCursorPos(1,1)
  46.       term.setTextColor( colors.white )
  47.       write("Logged in as "..username)
  48.      
  49.  
  50.     else
  51.       term.setTextColor(colors.red)
  52.       textutils.slowWrite("Access Denied!")
  53.       sleep(2)
  54.   end
  55.   else
  56.     write("Registered!")
  57.     f = fs.open("/users/"..username,"w")
  58.     f.write(password)
  59.     f.close()
  60.     f = fs.open("/balance/"..username,"w")
  61.     f.write("0")
  62.     f.close()
  63.     sleep(2.3)
  64.   end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement