Jump to content




How would I set up this

computer wireless

10 replies to this topic

#1 Sluethen

  • Members
  • 6 posts

Posted 21 July 2017 - 03:13 AM

So How would I make a login system that can read user's from a file? I'm new to this. I know how to make a login system but how would I Make it read and write to a file? I want it to read username's and password's from a file, but I'm not sure how.
Here is my current lock system. https://pastebin.com/sXnCsYyn

#2 Dave-ee Jones

  • Members
  • 456 posts
  • LocationVan Diemen's Land

Posted 21 July 2017 - 05:51 AM

Well, one way of doing it is saving a table full of usernames/passwords to a file, then importing the table into the program.
Look at textutils.seralize() and textutils.unserialize().

Another way is having a Users directory which has user files in it. So the name of the file is the username and the password would be saved in that file, raw or as a hash.
E.g.
- Users (directory)
  + admin (content: password)
  + tommy (content: theawesomeguy123)
  + jack (content: jh1240d845)

Then you can make a for loop that looks for a file in that folder with the name entered by the user logging in on the computer. Fairly easy if you know how to read/write to a file and use a for loop. :)

#3 Sluethen

  • Members
  • 6 posts

Posted 22 July 2017 - 02:32 AM

I don't know how to read and write to a file(well) I know how to sorta write to a file but reading is nothing I've learned.... I should look into reading and writing files

I'm also having a bit of trouble understanding how I would make it read each user

#4 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 22 July 2017 - 10:44 AM

For anything file-related, check out the FS API.

As for how to differentiate between users, you have a few options:

Option 1: Serialized Table - A table of users in the format tbl[ username ] = password. The table would be serialized and unserialized as necessary to write or read it from the file.

Option 2: Specialized file format - you could format your file in a particular way, eg. "username:password;username:password", then use string manipulation to extract the desired pairings. This would reduce file size compared to option 1, but is more difficult to implement.

Option 3: Multiple files - you could create a new file for each user (as suggested by Dave-ee Jones), where the file's name is the username and the contents is the password for that user.

Special Considerations: The majority of programs which store passwords in files make use of sha256, a hashing algorithm. This prevents someone from gaining access to the files on the computer and reading your password.

#5 Krul__Tepes

  • Members
  • 17 posts

Posted 22 July 2017 - 04:01 PM

this is what i need to figure out to make my phone program more advance

#6 Sluethen

  • Members
  • 6 posts

Posted 22 July 2017 - 04:54 PM

I've went and gone with Dave-ee's way, but I'm having trouble with making it write on other lines. for a Admin status. I've done it before but I'm either missing something or I'm failing.

#7 Sluethen

  • Members
  • 6 posts

Posted 22 July 2017 - 08:52 PM

It might help XD

#8 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 23 July 2017 - 12:47 AM

To write on a new line you just need to add a "\n" character to the end of the previous line.

For example,
"Hello\nWorld"
Would be written as:
Hello
World


#9 Sluethen

  • Members
  • 6 posts

Posted 23 July 2017 - 02:44 AM

Edit:Post has been eaten

Edited by Sluethen, 23 July 2017 - 03:35 AM.


#10 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 23 July 2017 - 02:48 AM

Sluethen, I would highly advise you to stop giving false advice. file.writeLine does not accept multiple parameters. Your example will write on multiple lines, but not necessarily the ones specified.

In addition, your comment on using "a" is extremely misleading. Append mode is very different from normal write mode!

Edited by KingofGamesYami, 23 July 2017 - 02:48 AM.


#11 Sluethen

  • Members
  • 6 posts

Posted 23 July 2017 - 03:35 AM

I'm not quite sure why I posted that. .-. I ate it.

Edited by Sluethen, 23 July 2017 - 04:12 AM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users