How is a password's hash is generated while a customer is registering?

The registration form’s block:

https://github.com/magento/magento2/blob/8fd3e8/app/code/Magento/Customer/view/frontend/layout/customer_account_create.xml#L14-L17

The registration form’s template with the «Create an Account» button highlighted:

https://github.com/magento/magento2/blob/8fd3e8/app/code/Magento/Customer/view/frontend/templates/form/register.phtml#L166-L166

The registration form’s action value (the URL where the form’s data will be sent):

https://github.com/magento/magento2/blob/8fd3e8/app/code/Magento/Customer/view/frontend/templates/form/register.phtml#L20-L20


https://github.com/magento/magento2/blob/8fd3e8/app/code/Magento/Customer/Block/Form/Register.php#L95-L103


https://github.com/magento/magento2/blob/8fd3e8/app/code/Magento/Customer/Model/Url.php#L173-L181

The server handles the data sent with the controller:

https://github.com/magento/magento2/blob/8fd3e8/app/code/Magento/Customer/Controller/Account/CreatePost.php#L197-L204

https://github.com/magento/magento2/blob/8fd3e8/app/code/Magento/Customer/Controller/Account/CreatePost.php#L219-L219


https://github.com/magento/magento2/blob/8fd3e8/app/code/Magento/Customer/Model/Session.php#L554-L564


https://github.com/magento/magento2/blob/8fd3e8/lib/internal/Magento/Framework/Session/SessionManager.php#L462-L482


https://github.com/magento/magento2/blob/8fd3e8/app/code/Magento/Customer/Controller/Account/CreatePost.php#L225-L225

https://github.com/magento/magento2/blob/8fd3e8/app/code/Magento/Customer/Controller/Account/CreatePost.php#L228-L228

https://github.com/magento/magento2/blob/8fd3e8/app/code/Magento/Customer/Controller/Account/CreatePost.php#L234-L235


https://github.com/magento/magento2/blob/8fd3e8/app/code/Magento/Customer/Model/AccountManagement.php#L599-L603


https://github.com/magento/magento2/blob/8fd3e8/app/code/Magento/Customer/Model/AccountManagement.php#L765-L774


https://github.com/magento/magento2/blob/8fd3e8/lib/internal/Magento/Framework/Encryption/Encryptor.php#L143-L143

https://github.com/magento/magento2/blob/8fd3e8/lib/internal/Magento/Framework/Encryption/Encryptor.php#L148-L150

https://github.com/magento/magento2/blob/8fd3e8/lib/internal/Magento/Framework/Encryption/Encryptor.php#L32-L35

https://github.com/magento/magento2/blob/8fd3e8/lib/internal/Magento/Framework/Encryption/Encryptor.php#L151-L153


https://github.com/magento/magento2/blob/8fd3e8/lib/internal/Magento/Framework/Math/Random.php#L24-L32


https://github.com/magento/magento2/blob/8fd3e8/lib/internal/Magento/Framework/Encryption/Encryptor.php#L155-L162

https://github.com/magento/magento2/blob/8fd3e8/lib/internal/Magento/Framework/Encryption/Encryptor.php#L62-L65


https://github.com/magento/magento2/blob/8fd3e8/lib/internal/Magento/Framework/Encryption/Encryptor.php#L168-L171


https://github.com/magento/magento2/blob/8fd3e8/lib/internal/Magento/Framework/Encryption/Encryptor.php#L27-L30


https://github.com/magento/magento2/blob/8fd3e8/lib/internal/Magento/Framework/Encryption/Encryptor.php#L67-L73


https://github.com/magento/magento2/blob/8fd3e8/app/code/Magento/Customer/Model/AccountManagement.php#L607-L607

The $hash consist of 3 parts, separated by :
https://github.com/magento/magento2/blob/8fd3e8/lib/internal/Magento/Framework/Encryption/Encryptor.php#L155-L162


https://github.com/magento/magento2/blob/8fd3e8/app/code/Magento/Customer/Model/AccountManagement.php#L610-L615

https://github.com/magento/magento2/blob/8fd3e8/app/code/Magento/Customer/Model/AccountManagement.php#L650-L650


https://github.com/magento/magento2/blob/8fd3e8/app/code/Magento/Customer/Model/ResourceModel/CustomerRepository.php#L187-L187

A password’s hash is stored in the Magento 2 database in the encrypted form:

https://github.com/magento/magento2/blob/8fd3e8/app/code/Magento/Customer/Setup/CustomerSetup.php#L245-L252

When a customer is imported by the standard Magento 2 tool, then you can set a plain password for the customer, and the hash will be generated automatically:

https://github.com/magento/magento2/blob/8fd3e8/app/code/Magento/CustomerImportExport/Model/Import/Customer.php#L363-L366

See also: