|
Main (PHP)
3rd Party Streams
Resources
Code Snippets
Affiliates
|
|
|
| |
Encryption using PHP |
| By admin (2007-10-11. 8195 views.) |
PHP has a built-in function to encrypt a string, crypt(clear, salt) that would allow for an easy mechanism for encrypting strings, such as passwords for applications. |
|
<?php The crypt function encrypts the passed string using DES. Optionally, a salt value may be passed to 'seed' the encryption. In reality, you would always provide a known salt otherwise every encryption call made would produce a different result. Also, note crypt since it's use of DES is a one-way encryption (assuming you don't have a crack team from the NSA available to decrypt a string)
For example, if we had stored a user password in a database in it's encrypted form we would have to know the salt value in order to later encrypt the password entered by the user to compare to the encrypted value stored in the database. ?>
|
| |
|
| |
|
|
|
|
|
|
|
|
Top Sponsor
Sponsors
Sponsors
Advertisting
Affiliates
|
|