Jump to content




Masking Input With Astricks (Password Style)


  • You cannot reply to this topic
7 replies to this topic

#1 NullSchritt

  • Members
  • 43 posts

Posted 22 July 2013 - 12: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.

#2 Grim Reaper

  • Members
  • 503 posts
  • LocationSeattle, WA

Posted 22 July 2013 - 12: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.

#3 NullSchritt

  • Members
  • 43 posts

Posted 22 July 2013 - 12:52 PM

View PostGrim Reaper, on 22 July 2013 - 12:33 PM, said:

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


#4 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 22 July 2013 - 12:54 PM

You're not checking the pass variable at all.

#5 Grim Reaper

  • Members
  • 503 posts
  • LocationSeattle, WA

Posted 22 July 2013 - 01:09 PM

What do you mean by it's not working?

#6 Thib0704

  • Members
  • 93 posts
  • LocationgetServer().getPlayer("Thib0704").getLocation();

Posted 22 July 2013 - 01:38 PM

What version of CC/Minecraft are you using ?

#7 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 22 July 2013 - 01:43 PM

View PostThib0704, on 22 July 2013 - 01:38 PM, said:

What version of CC/Minecraft are you using ?
The version of ComputerCraft has no bearing on this problem.

#8 NullSchritt

  • Members
  • 43 posts

Posted 22 July 2013 - 03:38 PM

Nevermind, I was updating the wrong pastebin code, it works perfectly now.

View PostLyqyd, on 22 July 2013 - 12:54 PM, said:

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





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users