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

Masking Input With Astricks (Password Style)

Started by NullSchritt, 22 July 2013 - 11:28 AM
NullSchritt #1
Posted 22 July 2013 - 01:28 PM
I have a couple of programs that I am using, one for locking doors, and one for dailing stargates.

In these two programs a password is requested from the user, but the problem is the password is typed out in plain text, for anyone to see who is also watching the screen.

Is there a way to mask the input, so that other users can't "spy" and steal it?

Thanks ahead of time! Love this mod.
Grim Reaper #2
Posted 22 July 2013 - 01:33 PM
There sure is:


local input = read ('*')

You can call read with a mask character like the code above. That code will use the asterisk as a mask when printing the input back out during the read call.
NullSchritt #3
Posted 22 July 2013 - 01:52 PM
There sure is:


local input = read ('*')

You can call read with a mask character like the code above. That code will use the asterisk as a mask when printing the input back out during the read call.
This doesn't seem to work, unless I am doing something wrong, below is my code.

os.pullEvent=os.pullEventRaw
id = os.getComputerLabel()
while true do
shell.run("redset right true")
shell.run("redset left true")
shell.run("clear")
print("Please enter the password to gain access to this area:")
pass = read ('*')
content = http.get("http://smp.projectbuilder.info/fetch.php?cmd=page&ID=doorcheck&buffer=0&NAME=" .. id .. "&PASS=" .. pass)
	 s = content.readAll()

if s == "1" then
shell.run("redset right false")
shell.run("redset left false")
print("Success, the door has been opened. Please enter the area promptly.")
sleep(6)
shell.run("redset right true")
shell.run("redset left true")
else
print("Error, incorrect password, please try again")
sleep(3)
end

end
Lyqyd #4
Posted 22 July 2013 - 01:54 PM
You're not checking the pass variable at all.
Grim Reaper #5
Posted 22 July 2013 - 02:09 PM
What do you mean by it's not working?
Thib0704 #6
Posted 22 July 2013 - 02:38 PM
What version of CC/Minecraft are you using ?
Cranium #7
Posted 22 July 2013 - 02:43 PM
What version of CC/Minecraft are you using ?
The version of ComputerCraft has no bearing on this problem.
NullSchritt #8
Posted 22 July 2013 - 04:38 PM
Nevermind, I was updating the wrong pastebin code, it works perfectly now.

You're not checking the pass variable at all.
Yes I am, I am checking it against a database via PHP page.