View Full Version : data encryption in php
I want to make a page/site which should have the security features such as encryption of data. how it can be done using php. do anybody can send some small portion of your code for an idea of how it can implement.
07-31-2007, 08:11 AM
07-31-2007, 12:45 PM
the above are all hash functions which are great for user password etc... if you want to encrypt and decrypt data you can use the mcrypt (http://www.php.net/mcrypt) functions
07-31-2007, 12:59 PM
how does the client get the key with these?
07-31-2007, 03:24 PM
You would need to "send" it to the client.
The encryption/decryption functions provided by the mcrypt library (to the best of my knowledge) are all symmetrical (uses the same key to encode and decode.) So, if someone intercepted the key or was given the key as a trusted client, they could encrypt data and make it appear like they were the originator (or they could decrypt your data, change it, encrypt it, send it on and it would appear to be the original data from you.)
If you have a situation where you want to insure that only you can encrypt data and the client can only decrypt it (and he would know the data was sent by you), you would need to use asymmetrical private/public key encryption/decryption. See the openssl functions to do this - http://php.net/openssl You still need to provide the public key to the client, but he can only decrypt using it. Anyone possessing the public key can decrypt data that you encrypted using the private key. Access to the keys must be restricted in any case.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.