PHP Programming/Encryption

PHP provides several functions to encrypt data.

Symmetrical encryption edit

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()[1]
  • openssl_decrypt()

Asymmetrical encryption edit

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()[2]
  • openssl_private_decrypt()

Hashing edit

crypt()[3] is a hash function for a string, which can add a salt as an optional second parameter.

References edit