411 REFERENCE · Wikibooks
PHP Programming/Encryption
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
PHP provides several functions to encrypt data.
Symmetrical encryption
Storing passwords in clear (unencrypted), in a file or a database, constitutes a security breach. To be able to encrypt and decrypt them, a symmetrical encryption can be done by:
openssl_encrypt()http://php.net/manual/en/function.openssl-encrypt.php
openssl_decrypt()
Asymmetrical encryption
The asymmetrical encryption est used to check an identity, via a public and a private key. In PHP, it's done with:
openssl_public_encrypt()https://www.php.net/manual/en/function.openssl-public-encrypt.php
openssl_private_decrypt()
Hashing
crypt()http://php.net/manual/en/function.crypt.php is a hash function for a string, which can add a Salt (cryptography) salt as an optional second parameter.
References