php bin/console security:hash-password
Hash a user password
Usage
security:hash-password [--empty-salt] [--] [<password> [<user-class>]]
Arguments
password The plain password to hash.
user-class The User entity class path associated with the hasher used to hash the password.
Options
--empty-salt Do not generate a salt or let the hasher generate one.
Help
The security:hash-password command hashes passwords according to your
security configuration. This command is mainly used to generate passwords for
the in_memory user provider type and for changing passwords
in the database while developing the application.
Suppose that you have the following security configuration in your application:
# config/packages/security.yml
security:
password_hashers:
Symfony\Component\Security\Core\User\InMemoryUser: plaintext
App\Entity\User: auto
If you execute the command non-interactively, the first available configured
user class under the security.password_hashers key is used and a random salt is
generated to hash the password:
php bin/console security:hash-password --no-interaction [password]
Pass the full user class path as the second argument to hash passwords for
your own entities:
php bin/console security:hash-password --no-interaction [password] 'App\Entity\User'
Executing the command interactively allows you to generate a random salt for
hashing the password:
php bin/console security:hash-password [password] 'App\Entity\User'
In case your hasher doesn't require a salt, add the empty-salt option:
php bin/console security:hash-password --empty-salt [password] 'App\Entity\User'