What’s this upcoming “Encryption” component of Symfony 6.1?

Photo by Viktor Forgacs on Unsplash
openssl_encrypt method’s signature
Interfaces bundled within the component
  • generateKey, which allows you to define how you’re going to build your own KeyInterface. You can pass it an optional secret (again, also called passphrase) ;
  • encrypt to simply encrypt your data with a given key. It will use the secret part of the key (which differs from the functions we’re going to see in a minute). You pass your data through the $message argument. Remember: even if its string typed, PHP allows you to easily define binary data in strings. This way, you can even encrypt unformatted data!
  • encryptFor is used to encrypt data for somebody. It will use the public part of the key to encrypt data. This way, encrypted data can only be decrypted using the private key that is mathematically linked to this public key. Super useful if someone sent you their public key and you want to be sure only this person will be able to see your data.
  • decrypt is used to… well, decrypt data. Simply give it your encrypted data, your key and if everything matches, it will return the decrypted message.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store