Encryption Key in Magento2.x

  • Magento encryption key is use to protect the password, credit card data, payment/shipment module data and other sensitive data in magento website.
  • AES-256 algorithm is used to encrypt all the data that requires for decryption. SHA-256(secure Hash Algorithm) is used to hash all data that not require decryption. This key is used to maintain the data secure in magento DB.
  • Mainly this key is required on magento cloud environments setup. Also mainly this encryption key is required when we migrate the website from one host to another.
  • Magento is suggesting to change the key at regular basic to improve the magento website security. While first time magento installation system will generate key automatically and it will be stored in app/etc/env.php.
  • After setup even we also change the key from admin panel section. Magento Data will be re-encoded using new key once after configure the new key from env.php file.

Encryption Key configuration Path:
root> app/etc/env.php
Under crypt section -> Key will be available
Suggestion : Don’t share this key .

To generate new key from admin section:

Goto admin -> system -> Manage Encryption Key

Here you will get two different way to generate the key.
1.Auto generation key : Magento will generate these key automatically
2. New key : With our choice we can enter the key & generate. But if you are going to enter than the Encryption key must be 32 character string without any white space.

Note: Your app/etc/env.php file is required with full writable permission while generating the key via admin. If the file doesn’t have  the required write permission than we need to copy & paste it by manual.

Save Tree!!! Save Water !!!