I made a program that allows people to put a password on a program, or entire computer there is a large amount of applications for this hope you all find it useful. -- i have done something like this before but this is both more versatile and written better. Code: --Lock Ver 2.0; script by fxstriker. function reset() term.clear() term.setCursorPos(1,1) end function lockout() l = l + 1 reset() print("-1 of 3 Attempt's") sleep(1) if l == 3 then reset() wait = 60 while wait > 0 do sleep(1) reset() print("System Locked.") print(wait) wait = wait - 1 end else loginUser() end loginUser() end --loginUser() function loginUser() reset() print("Please enter username: ") username = read() if username == "Admin" then --username goes here change "Admin" w/quotes print("Correct.") sleep(1) loginPw() else reset() print("Wrong Username") lockout() end end function loginPw() reset() print("Please enter password: ") password = read("*") if password == "password" then --password goes here change "password" w/ quotes print("Login sucesfull.") sleep(1) else reset() print("Wrong Password.") lockout() end end os.pullEvent = os.pullEventRaw l = 0 loginUser() reset() --Code to run after authentication goes here. Note: the comments in the code say what lines to edit by default the log in is Admin password save program as startup Here is a log out script i wrote save it as log out Code: term.clear() term.setCursorPos(1,1) print("Loging out") x = 5 term.setCursorPos(1,2) while x > 0 do sleep(1) write(".") x = x - 1 end os.reboot()
There are a few security flaws in this code for you to consider. 1. Username is verified before password entry. 2. Password is stored as plaintext. 3. Authentication can be bypassed. (Try terminating the script using CTRL+T.)
usernames are meant to be before pw passwords plain text cannot be viewed without first logging in to the system you cant terminate the script that is what the pull event is i extensively tested it.
well this is different, one could use it on an entire computer protecting it and all its directory's or implemented with other code + i was board and couldn't think of anything to do =p
Striker, it looks good, and the lockout system is a nice feature to have, but perhaps it should undo the Ctrl+t lockout and just exit to the shell once you login, which wouldn't be hard to do and would be more usable by general users as a "password on startup" type script. Id suggest an online/local account hybrid interface if I had my own system online .