Skip to content

Instantly share code, notes, and snippets.

@ainsofs
Last active January 23, 2025 02:30
Show Gist options
  • Save ainsofs/089b67215bd221f520e46893a5ff0d36 to your computer and use it in GitHub Desktop.
Save ainsofs/089b67215bd221f520e46893a5ff0d36 to your computer and use it in GitHub Desktop.
Salt generator for drush

https://drupalsun.com/eelke/2018/08/24/quick-tip-generating-hash-salt-drupal-8

Use this to generator a salt hash so that its not included in your settings.php file if you commit that file to your repo.

cli

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

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

settings.php

$settings['hash_salt'] = file_get_contents('../salt.txt');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment