That's nice. Thank you. One of the next steps in my PHP learning project is to encrypt data on a database for user information, such as e-mail addresses.
No, if you're using sessions, use the built-in session handing in PHP. You would use this if you wanted to encrypt some data when storing it, for example if you develop an API that has users, each with an API key. In the same way that we store password hashes, you might store the API key encrypted in the database so that if the database is compromised, they don't have the plaintext API keys.
For those who are new to encryption, please not that encryption alone is not enough, typically. You also need to authenticate which guarantees that when decrypt the ciphered text, you get the original text "Hello world!" not some gibberish text. Ckeck out these 2 sodium functions for example: sodium_crypto_aead_xchacha20poly1305_ietf_encrypt sodium_crypto_aead_xchacha20poly1305_ietf_decrypt
Great video on encryption. When encrypting data using PHP, do you know if the encrypted data be decrypted using other languages? Say in JS, C#, C++ etc? Thanks
Thank you! Good question. I suppose if the same algorithm were used, along with the same key and nonce / iv, then in theory you should be able to decrypt using a different language. I'll give it a try when I get a minute, it would be interesting to know!
Thx! Can you show how to encrypt and decrypt using PGP keys? The goal would be to send encrypted /signed emails automatically. Would love to see a tutorial how to retrieve the recipients key and use it for it.