mikk809h

PassProg[test]

Dec 6th, 2012
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.01 KB | None | 0 0
  1. local edit = false
  2.  
  3. local functions = {
  4. "edit",
  5. "-^- Edit your password"
  6. }
  7.  
  8. local function fRead()
  9. if fs.exists(".@Main@./Config.cfg") then
  10. fs.isLocked = false
  11. fRead1 = fs.open(".@Main@./Config.cfg", "r")
  12. fPass = fRead1.readLine()
  13. fRead1.close()
  14. fs.isLocked = true
  15. else
  16. print("Error..... opening_error")
  17. sleep(3)
  18. end
  19. end
  20.  
  21. local function fNew()
  22. fs.isLocked = false
  23. fWrite1 = fs.open(".@Main@./Config.cfg", "w")
  24. fWrite1.writeLine(nPass2)
  25. fWrite1.writeLine("3.0")
  26. fWrite1.writeLine("0.0")
  27. fWrite1.close()
  28. fs.isLocked = true
  29. end
  30.  
  31. function askTODO()
  32. term.clear()
  33. term.setCursorPos(1,1)
  34. print("Type edit to edit password... type other words to exit")
  35. print("\n"..functions[1].." - this function is avaible")
  36. print("\n"..functions[2])
  37. write("\n your input > ")
  38. input = read()
  39. if input == "edit" or input == "Edit" or input == "EDIT" then
  40. edit = true
  41. else
  42. edit = false
  43. end
  44. end
  45.  
  46. askTODO()
  47.  
  48. if edit then
  49.             print("Do you want to edit your current password?")
  50.             write(" Y or N > ")
  51.             YN = read()
  52.                 if YN == "Y" or YN == "y" then
  53.                     print("Please type your current password: ")
  54.                     write("> ")
  55.                     cPass = read("#")
  56.                         if cPass == fPass then
  57.                             print("Please type new password: ")
  58.                             write("> ")
  59.                             nPass1 = read("@")
  60.                             print("Please confirm new password: ")
  61.                             write("> ")
  62.                             nPass2 = read("#")
  63.                                 if nPass2 == nPass1 then
  64.                                     fNew()
  65.                                     term.clear()
  66.                                     term.setCursorPos(1,1)
  67.                                     print("Password set...")
  68.                                     print(nPass2)
  69.                                     sleep(5)
  70.                                     os.reboot()
  71.                                 else
  72.                                     term.clear()
  73.                                     term.setCursorPos(1,1)
  74.                                     print("Your passwords does not match...")
  75.                                     sleep(2)
  76.                                     term.clear()
  77.                                     term.setCursorPos(1,1)
  78.                                 end
  79.                         else
  80.                             print("your input, does not match to the current password!...")
  81.                             sleep(4)
  82.                             term.clear()
  83.                             term.setCursorPos(1,1)
  84.                         end
  85.                 else
  86.                     term.clear()
  87.                     term.setCursorPos(1,1)
  88.                 end
  89. end
  90. fs.isLocked = true
Advertisement
Add Comment
Please, Sign In to add comment