Advertisement
Guest User

startup

a guest
Jan 31st, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.76 KB | None | 0 0
  1. while true do
  2. term.clear()
  3. if fs.exists("/disk/id") then
  4.   content=fs.open("/disk/id", "r")
  5.   line=content.readLine()
  6.   limit=0
  7.   for i=1, string.len(line) do
  8.     if string.sub(line, i, i) == ":" then
  9.       limit=i
  10.       break
  11.     end
  12.   end
  13.   user=string.sub(line, 1, limit-1)
  14.   hash=tonumber(string.sub(line, limit+1, string.len(line)))
  15.   content.close()
  16.   print("Identified as " .. user)
  17.   term.write("Enter your password: ")
  18.   pass=read("*")
  19.   hashed=1
  20.   for i=1, string.len(pass) do
  21.     hashed=hashed+157*string.byte(pass, i)
  22.     if i % 2 == 0 then hashed=hashed*503
  23.     else hashed=hashed*947
  24.     end
  25.   end
  26.   if hashed == hash then
  27.     print("Connected")
  28.   else
  29.     print("Wrong password")
  30.   end
  31. else
  32.   print("Enter your ID")
  33. end
  34. sleep(5)
  35. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement