Advertisement
LegoStax

Lithium OS Login

Sep 30th, 2013
404
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.92 KB | None | 0 0
  1. --[[
  2.     Security Login using GravityScore's SHA-2 Encryption
  3.     Security Login - by LegoStax
  4. ]]--
  5. os.pullEvent = os.pullEventRaw
  6. -- Load Login Image
  7. bg = paintutils.loadImage(".programs/login_img")
  8. paintutils.drawImage(bg, 1, 1)
  9. -- Load Grav's SHA
  10. os.loadAPI(".programs/sha")
  11. -- check for user info
  12. if fs.exists(".programs/user") then
  13.     -- get table
  14.     info = {
  15.         cpass = nil;
  16.         user = nil;
  17.     }
  18.     local file = fs.open(".programs/user", "r")
  19.     info = textutils.unserialize(file.readAll())
  20.     file.close()
  21. end
  22. -- Check Textboxes Function
  23. function checkPass(user, msg)
  24.     checkpass = sha.sha256(msg)
  25.     if user == info.user and checkpass == info.cpass then
  26.         shell.run("lithos")
  27.     else
  28.         paintutils.drawImage(bg, 1, 1)
  29.     end
  30. end
  31. -- Main
  32. term.setBackgroundColor(colors.lightGray)
  33. while true do
  34.     term.setCursorPos(14,12)
  35.     write ""
  36.     user = read()
  37.     term.setCursorPos(14,17)
  38.     write ""
  39.     pass = read("*")
  40.     checkPass(user, pass)
  41. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement