WordPress salt key generator
Everything runs in your browser; nothing is sent or stored.
- When the page opens, the "define() lines to paste" field shows the definitions of all the constants, with random keys.
- Click "Generate new keys" to replace all the keys in the field, and click "Copy all" to copy all the lines.
- Before you edit the wp-config.php file, save a copy of it so you can restore it if something goes wrong.
- In the wp-config.php file, replace the existing lines, from AUTH_KEY to NONCE_SALT, with the copied lines, and save the file. Replacing the keys logs out every logged-in user of the site, and each of them has to log in again.
What WordPress keys and salts do
WordPress uses the keys and salts in the wp-config.php file to sign the login cookies of users and the security tokens (nonces) that protect forms and actions in the WordPress admin area. Each key has a matching salt, for example AUTH_KEY and AUTH_SALT, and WordPress combines the two values to calculate the signature. Because the signature is based on these secret values, someone who does not know them cannot create a valid login cookie, even if they know the username.
When to change the keys
After a site is hacked, or when you suspect that the wp-config.php file was exposed, for example in a backup saved in a public folder, replace the keys, because replacing them immediately invalidates all existing login cookies. Replacing the keys is also a good idea when an employee or a contractor with admin access finishes working on the site, because the login cookie saved in their browser stops working. User passwords do not change, and every user logs in again with their existing password.
Structure of the lines in wp-config.php
Each line defines one constant with the define() function, and the value is enclosed in single quotes. The keys that the generator creates include letters, digits, symbols, and spaces, and they do not include a single quote (') or a backslash (\), so you can paste them as is. After you paste them, make sure that each constant is defined only once in the file, because defining a constant twice causes a PHP warning.
The keys in wp-config.php and what they do
AUTH_KEYsigns the login cookie for the admin area over an HTTP connection.SECURE_AUTH_KEYsigns the login cookie for the admin area over an HTTPS connection.LOGGED_IN_KEYsigns the cookie that identifies a logged-in user on the pages of the site.NONCE_KEYsigns the security tokens (nonces), which prevent forms and actions from being submitted on behalf of a user without their knowledge.
With our WordPress hosting, dedicated protection for WordPress sites works alongside a WAF and antivirus.
WordPress salt key generator FAQ
What happens when the keys are not defined in wp-config.php?
When a constant is not defined in the file, or its value is still the text "put your unique phrase here" from the sample file wp-config-sample.php, WordPress generates a random value and saves it in the database. A value saved in the database is visible to anyone who has access to the database, so we recommend defining all the constants in wp-config.php.
Are the spaces and symbols in the keys valid?
Yes. The spaces and symbols are valid, because WordPress reads all the characters between the quotes as a single value. Each key is 64 random characters long, like the keys that the WordPress.org service generates.
Does changing the keys affect plugins?
Some plugins use the keys to encrypt settings, such as connection tokens for external services. After you change the keys, a plugin that encrypts its settings with the keys cannot decrypt the saved settings, and you need to reconnect it to the service in the plugin settings.
Can I use the same keys on several sites?
Every WordPress installation needs its own unique keys. When several sites use the same keys, exposure of the wp-config.php file on one site also affects the security of the other sites. In a WordPress Multisite network, all the sites share one wp-config.php file, and therefore the same keys.
Can I change the keys from the command line?
Yes. On a server with WP-CLI installed, the command wp config shuffle-salts replaces all the keys in wp-config.php with new random values. Run the command from the root folder of the site, and when you run it from another folder, specify the folder of the site with the --path option.