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

Simple login program

Started by ntnick, 07 May 2014 - 01:52 PM
ntnick #1
Posted 07 May 2014 - 03:52 PM
Here's a simple login program that I made a few minutes ago. It runs only on advanced computers, a non-colored computer version will be coming soon.

Screenshot:



To get it, type:


pastebin get nLaN9KfB startup

Change the username and password in the "password" table, and you'll be good to go.

Regards,

Nick
Lyqyd #2
Posted 07 May 2014 - 07:19 PM
Cleaned this up. If you're going to critique a program, make sure to use constructive criticism and try to help them improve their program.
viluon #3
Posted 07 May 2014 - 07:34 PM
Cleaned this up. If you're going to critique a program, make sure to use constructive criticism and try to help them improve their program.
You're right, sorry for that
TheOddByte #4
Posted 07 May 2014 - 07:46 PM
Ok, so this seems pretty decent but is also very insecure.
I have a few tips for you
  • Make variables local (such as the table password)
  • Add ctrl+t prevention
  • Use a loop instead of calling functions recursively
I'm sure you know how to do the first of these things since I see that you've done local variables in the function.
The second one is very easy, Here's the code snippet

os_pullEvent = os.pullEvent -- Storing the old function in a variable
os.pullEvent = os.pullEventRaw -- Overriding it with os.pullEventRaw

-- Your code

os.pullEvent = os_pullEvent -- Restoring the old pullEvent function, put this when the user have entered the correct credentials
bigbrainiac10 #5
Posted 07 May 2014 - 11:34 PM
I've got some things I think you should add:
  • Add support for multiple users, you could do that by using the following:
    
    local users = { {"SomeUsername", "SomePassword"}, {"SomeOtherUsername", "SomeOtherPassword"} }
    
    term.clear()
    term.setCursorPos(1,1)
    
    term.write("Username: ")
    local user = read()
    
    term.setCursorPos(1,2)
    local pass = read("*")
    
    for _,u in pairs(users) do
    if (user == u[1]) and (user == u[2]) then
    --stuff
    else
    --other stuff
    end
    end
    
  • Also, for extra security I'd recommend downloading tomass1996's StrUtilsAPI and use it to hash your passwords.
  • If you wanted to be even more secure you could use rednet and have all of the code that manages passwords and such on a server computer.
Hope I gave you some good ideas :)/>
InputUsername #6
Posted 08 May 2014 - 09:24 PM
-snip-
  • If you wanted to be even more secure you could use rednet and have all of the code that manages passwords and such on a server computer.
Heh. More secure. Right. ;P

Anyway, nice and simple. Maybe you could add the things mentioned by the others?
bigbrainiac10 #7
Posted 08 May 2014 - 10:23 PM
-snip-
  • If you wanted to be even more secure you could use rednet and have all of the code that manages passwords and such on a server computer.

-snip snap-

Well, yeah… I personally would encrypt my rednet messages with a key, you wouldn't send information as plain text for obvious reasons, such as port scanner programs.
ntnick #8
Posted 29 May 2014 - 12:54 AM
I'm probably not going to make updates anymore, as this was just a small program.
Thanks for your suggestions, though.