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

need some help

Started by Siftos31, 06 February 2016 - 06:21 AM
Siftos31 #1
Posted 06 February 2016 - 07:21 AM
I'm good on programming but I need some help

How can I do a password locked os so u can do ur own password and login and logout

sorry for my english I'm from sweden

thanks for help
Lyqyd #2
Posted 06 February 2016 - 07:32 AM
Moved to Ask a Pro.
Lupus590 #3
Posted 06 February 2016 - 02:42 PM
If the password is to be changeable then you will have to store it in a file, this will need the FS API

You may want to look into encrypting that file, there are several encryption APIs on the forums: http://www.computercraft.info/forums2/index.php?app=core&module=search&do=search&fromMainBar=1

Logging in is asking the user to input something and then comparing that to the password. If you have your program run the shell then they can logout with the exit command.

You will need to make the program run on startup, you may want to provide another file to startup from.
Edited on 06 February 2016 - 01:45 PM
HPWebcamAble #4
Posted 06 February 2016 - 05:44 PM
You may want to look into encrypting that file, there are several encryption APIs on the forums: http://www.computerc...h&fromMainBar=1

You should hash passwords when storing them. You don't need to encrypt them. Here's a good Hashing API: http://www.computercraft.info/forums2/index.php?/topic/8169-sha-256-in-pure-lua/
EveryOS #5
Posted 19 February 2016 - 01:15 PM
I'm good on programming but I need some help

How can I do a password locked os so u can do ur own password and login and logout

thanks for help

In develepment I have an Os that asks for a password system at startup

Here are the main password files:

–something/password–
–[leave field blank, press save, do not type this comment in]—

–startup–
shell.run('something/startup')

–something/startup-
passwordf=io.open('something/password','r')
password=passwordf:read()
passwordf:close()
print('Password Please?')
if password==nil then
term.clear()
term.setCursorPos(1,1)
shell.run('something/createpassword')
shell.run('file')
else if read('*')==password then
shell.run('file')
else
print('incorrect')
sleep(1)
os.shutdown()
end
end

–something/createpassword–
print('You neeeed a password. You can currently only have one password, and no usernames')
pw=io.open('NyanOs/password','w')
pw:write(read('*'))
pw:close()