Engine of a Mini Seven racing Mini
Photo: Copyright © 2009 Eelke Blok

Quick tip: generating a hash salt for Drupal 8

Drupal 8 will actively complain when your site does not have a hash_salt configured, which usually gets generated when installing the site. (The complaint, mind you, might be fairly obscure; your site might just say "The website encountered an unexpected error. Please try again later." Depending on your error reporting settings, the message might be a bit more helpful). If, for example, you "install" a site by copying over a database and files, you will not have this.

When you need a fresh site hash, you can use the following Drush command.

drush php-eval 'echo \Drupal\Component\Utility\Crypt::randomBytesBase64(55) . "\n";'

Alternatively, if you would like to put it in a file, so that you can read the file from somewhere outside your webroot, you could do:

drush php-eval 'echo \Drupal\Component\Utility\Crypt::randomBytesBase64(55)' > salt.txt

To quote the comment from default.settings.php:

 * Example:
 * @code
 *   $settings['hash_salt'] = file_get_contents('/home/example/salt.txt');
 * @endcode

 

Comments

Add new comment