Sorry it took so long to understand how it works. Actually I waited with it untill today, because my bro suddenly bought two Lord of the Rings games and I couldn't stand not playing them before I continue.
Well, now I read the help file I think I understand it now. You actually just generate a public file, and if people want to send an encrypted message that you can decrypt to you, they first need your public file, load it, generate the encrypted text and send it to you. Then you need your own public file plus your private file to decrypt it. Note no one else can decrypt the messages sent to you even if they have your public file, because they also need your private file to decrypt. Great.
Now I'm thinking about the best method to import this in my game so the passwords and other account data will get protected. If I am right, this encryption can only be used for communication, if you just need to encrypt some strings/files on your own local harddrive, you better use another encrypting method, because if you use this method you got that private file and public file on your pc and whole the stuff that are not needed. So actually I need two encryptions for my mmorpg. This one, used to send the password and other account data to the server, and another simple one just to encrypt the local data. Because, if they send the encrypted data using the servers public key, I will decrypt it on my server, and then encrypt it with a non-communication encryption method just to store it on my pc. So it's like this:
Drawn by me. Such art. ;D
Can someone comment my method? I don't know if this is the most efficient or even right method. =/
Btw. Sorry for the double post, I forgot I already replied yesterday, I'm such an idiot.
"Secure" password stoarage is easy... although to truly make it secure, you can't actually retrieve the password if it is lost, you can only reset it.
Here's how it works, in case this hasn't been explained...
User types in his password when he creates the account
The password is encrypted (in PHP you use md5, which is almost uncrackable)
The encrypted password is sent to the server, and stored with the user's info
When the user wants to log in, he types in his password, as normal
The password is encrypted using the same algorithm as before, and sent to the server
The server compares the sent password to the one that is stored
If they match, then the user is free to continue, if not, the user is prompted again
This way you are secure in two ways...
If the account is hacked, and someone downloads the user's info, the encrypted password (unless somehow decrypted) is useless. Because whenever the user sends his info to be verified, the password text is run through the encryption algorithm, and hence, just knowing the encrypted password would not work. Entering the encrypted password into the password field, and trying to submit it to the server would yield a double encrypted password, which would not be the same as the encrypted password already stored on the server.
Second, the same goes for if the information that is being sent to the server is intercepted by a hacker... It's still the same old useless encrypted info.
Of course, there are security flaws with every system... but this is the type I use on all the PHP sites I've coded, and it seems to work just fine.
Hopefully I'm not way off topic by posting this, just thought you might find it useful!
Edited by FredFredrickson, 04 August 2005 - 03:06 AM.