![]() |
|
#1
|
||||
|
||||
creating password protected filesHi, I'm creating a program that will be updating/adding data to several files. I would like the program to prompt the users for a password/login before it allows them to make changes. Is there anyway I can do this without using a database to store the passwords/usernames? If anyone has any good links to a website that explains how to do this, that would be great too. Thanks for all the help
__________________
"To argue with a person who has renounced the use of reason is like administering medicine to the dead." -Thomas Paine www.sullivan-county.com/deism.htm |
||||
|
#2
|
||||
|
||||
Re: creating password protected filesThe easiest way is to read and write a login file -- in binary. If you don't need the password to be extremely secure, you can encrypt the password using any simple algorithm that you can find using Google and output the values as long integers once encrypted.
__________________
The 3 Laws of the Procrastination Society: 1) Never do today that which can be put off until tomorrow 2) Tomorrow never comes |
|
#3
|
||||
|
||||
Re: creating password protected filesThanks for the suggestion Walt. I've now hit a different issue. I'm trying to create a function that will remove old users from the password file. The program prompts for who you would like to remove, and then searches the file for that user. Currently the only way I can think of removing the user it to dump all the users out of the file (into a linked list), find the user I want to remove, delete his node in the list, and then dump the list back into the file (overwrighting it in the process). Can anyone think of a better way to do this? My method seems a bit "bulky" for something this simple.
__________________
"To argue with a person who has renounced the use of reason is like administering medicine to the dead." -Thomas Paine www.sullivan-county.com/deism.htm |
|
#4
|
||||
|
||||
Re: creating password protected filesokay, here is my latest problem. This is related to my original post so I'm not creating a new one. I have a little program that will add/remove new users to a binary file. It seems to be adding users fine. I say seems to, because I can't view the file to be sure. I created a view function but it seems to be printing junk if more then one entry is in the file. I haven't even touched the remove function because it just seems to crash the program and delete the file. Here is my code. Any help would be, well helpful:
CPP / C++ / C Code:
__________________
"To argue with a person who has renounced the use of reason is like administering medicine to the dead." -Thomas Paine www.sullivan-county.com/deism.htm |
|
#5
|
|||
|
|||
Re: creating password protected filesQuote:
What is sizeof(logInInfo)? For a 32-bit system, I would expect it to be 8. The string objects themselves are stored somewhere else, and the struct elements point to them. So... you aren't actually writing the strings each time, you are writing two pointers. Note that the size of the struct is fixed, but the strings themselves can have any length. See footnote. Everything else from here on has to be downhill because: The next time that you run the program, when you read pointer values in from a file, they don't necessarily point to anything legal within that current program space. Then, when you dereference them (by trying to store the items in memory that they are supposed to be pointing to) the program can bomb. (So, don't do it: Don't write pointers and read them back and expect something Good to happen.) If you want to write variable-length data (like names and/or passwords) to a binary file, then in order to read them back, you must have some way of knowing when one datum ends and the next one begins. If the data can be sequences of arbitrary binary byte values, it's not simple. (That's why we use text files; the files are structured into "lines" separated by "newline" chars. Reading the "strings" is OK as long as the strings themselves don't contain any zero-byte chars.) I think a little rethink might be in order: Either make names and passwords fixed-length arrays of chars (or whatever) so that all records have the same size, or devise some way of delimiting names and passwords so that you can read back whatever you write. For example you could use text files with some encryption scheme that always maps sequences of ascii chars to sequences of printable ascii chars so that it's easy to tell where one starts and the other ends. Regards, Dave Footnote: In general, it is never possible to write C++ std::strings using sizeof() to designate the length. (That's right:Never.) The value of "sizeof(anything)" is constant, and it is evaluated at compile time. The "sizeof" a C++ std::string is equal to the size of a pointer. |
|
#6
|
||||
|
||||
Re: creating password protected fileswell damn. That's a day of wasted time. I like the ideal of the fixed length arrays. I'll start over and see what happens. Once again thanks for all the help.
__________________
"To argue with a person who has renounced the use of reason is like administering medicine to the dead." -Thomas Paine www.sullivan-county.com/deism.htm |
Recent GIDBlog
Vista ?Widgets? on Windows XP by LocalTech
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| automatic password protected web folder reset | rgrant | Web Design Forum | 0 | 30-Aug-2006 08:25 |
| Bloodshed Dev C++ Project Options | JdS | C++ Forum | 6 | 11-Nov-2005 17:23 |
| "HTML Help Workshop" to creating help files | shinyhui | MS Visual C++ / MFC Forum | 0 | 08-Aug-2005 03:52 |
| Can't view pages from another machine on the Intranet | aevans | Apache Web Server Forum | 9 | 14-May-2004 02:26 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The