Wow thank you guys for all the really interesting ressource and answers. As Grime was right to point out, I was asking merely for a simple fun project I'm developing for my personal enjoyment and because how else than by coding can can you learn coding better?
For those who are interested in knowing the whats and whys for my question, here is my previous post :
http://www.cplusplus.com/forum/general/248842/
That being said, even though I
wasn't looking to get into proper security and hashing I think all of the answers above are piquing my curiosity and interest.
@helios
Thanks, this one seems really interesting, I'll look into it!
@Ganado
Thanks for bringing to my attention all those methods of hashing/encrypting, I tried to do some research but I was overwhelmed by the number of mishmash of libraries and databases and whatnot I found on the subject, and really didn't know where to look / start.
@Grime
Who knows maybe hoogo was secretly developing a new search engine or something. |
Hmmmm who knows, one may have many secrets hidden in dark places... :D Naah actually you're right, it's for my app I mentioned in an older post. Indeed I'm not trying to prevent any *hacking* per se, since the app isn't online. I'm in fact just trying to avoid anyone opening a .data file with a text editor like notePad++ or even notePad and finding my user credentials written in binary, which is still visible since it's one char array for the username and one for the password (currently).
@jonnin
cin integer password.
seed random generator to that integer.
for all the letters you want to encrypt, just xor them with the next random value.
write that to the file. it will be binary, not text, be careful of this.
the exact same code decrypts it. |
That sounds more like encrypting than hashing (correct me if I'm wrong). I don't want to have to use a key to decrypt an encrypted password. My logic would be the following:
-> User creates username and password
-> Username is stored on X.data file
-> Password is hashed by a function and then stored on X.data file
_when user goes to log in_
-> User enters username, username is read from X.data file, usernames are compared
-> User enters password, password is hashed, hashed password is read from X.data file, hashed passwords are compared
-> If both usernames and hashed password are identical, user is logged in
What matters to me: the password is 'physically' written nowhere.
@Ganado
Yep, agreed, that's fine and can be fun for personal projects. (I just think it's obligatory to let anyone know that for any serious project, rolling your own is unwise and error-prone.) |
Right on yes, for now it's for a fun personal project but I might need that info and knowledge later, so cheers!