This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
ew0345's profile picture

Password Protections

Started by ew0345, 29 April 2014 - 10:10 PM
ew0345 #1
Posted 30 April 2014 - 12:10 AM
This is kinda just a cool password protection for computercraft computers! :)/>


-- To change the password look for "if input == "password" then" and change "password" to what you want the password to be.
os.pullEvent = os.pullEventRaw
term.clear()
term.setCursorPos(1, 1)
term.setTextColor(colors.blue)
term.setBackgroundColor(colors.red)
write("Please enter password: ")
local input = read ("*")
if input == "password" then
	    term.clear()
	    term.setCursorPos(1, 1)
	    print("Logging in, Please wait...")
	    sleep(3)
	    term.setCursorPos(1, 1)
	    term.setTextColor(colors.yellow)
	    term.setBackgroundColor(colors.black)
	    term.clear()
	    print("CraftOS 1.5 -- Password Secured")
else
	    term.clear()
	    term.setCursorPos(1, 1)
	    term.setTextColor(colors.red)
	    term.setBackgroundColor(colors.blue)
	    term.clear()
	    print("FATAL ERROR")
	    print("")
	    print("")
	    print("")
	    print("")
	    print("")
	    print("")
	    print("Password Wrong")
	    print("")
	    print("")
	    print("Shutting down CraftOS 1.5...")
	    print("")
	    print("")
	    print("")
	    print("")
	    print("")
	    print("")
	    print("")
	    sleep(3)
	    os.shutdown()
end

Pastebin Link: http://pastebin.com/uG1BqCtR
Saldor010 #2
Posted 30 April 2014 - 02:31 PM
Isn't this just another lock program..? Also, useless sleeps FTW! (Sarcasm)
Blue #3
Posted 01 May 2014 - 06:39 AM
i'm going to give a few reasons about why this is bad:
1.How are you sure that the user is going to have craftos 1.5
2.Your program is simply setting a variable and then checks if the user's input is equal to that variable. The better way to do it is to use fs.open
3.too many sleeps
4.

			term.setTextColor(colors.yellow)
			term.setBackgroundColor(colors.black)
What is the point in that.
5.why do print"" when you can do term.setCursorPos
6.if someone enters the wrong password it will skip a few lines.What is the point in that.
7."FATAL ERROR".Why is it a fatal error when you enter the wrong password?What is the point in that.
8 .i had to say three times the phrase:"what is the point in that"
sorry if i was bit harsh and for the spelling mistakes.I'm tired :(/>
Edited on 01 May 2014 - 04:42 AM
CoLDarkness #4
Posted 01 May 2014 - 01:05 PM
Now, this might be offensive to the both at one point.

1. To all these guys judging him, he probably is a newbie.

2. If you are a newbie and you registered on forums, maybe you should've looked into the section a little bit more before understanding what is absurdly easy and what is not.
Blue #5
Posted 01 May 2014 - 02:13 PM
a little tutorial on fs.open

local h=fs.open("password","r") --opens the file named "password"
local pass=h.readLine() --reads the first line of the file
h.close()
local password=read() --saves the input in a password variable
if password==pass then --if password is correct
print("Access granted!")
else print("Access denied") --if not then
os.shutdown()
end

hope this helps! :)/>

Now, this might be offensive to the both at one point.

1. To all these guys judging him, he probably is a newbie.

2. If you are a newbie and you registered on forums, maybe you should've looked into the section a little bit more before understanding what is absurdly easy and what is not.
i was only trying to help!
cdel #6
Posted 06 May 2014 - 11:49 AM
very nice, however not very 'safe' or 'efficient' I can you help you with encryption if you wish :)/>

EDIT: PM me :D/>
Edited on 06 May 2014 - 09:49 AM