Change Customer Password Programmatically in Magento2:- In this blog I’ll explain you how we can change customer password programmatically.
$customerId = 1; // here assign your customer id
$password = "custom_password"; // set your custom password
$customer = $this->_customerRepositoryInterface->getById($customerId); // _customerRepositoryInterface is an instance of \Magento\Customer\Api\CustomerRepositoryInterface
$customerSecure = $this->_customerRegistry->retrieveSecureData($customerId); // _customerRegistry is an instance of \Magento\Customer\Model\CustomerRegistry
$customerSecure->setPasswordHash($this->_encryptor->getHash($password, true)); // here _encryptor is an instance of \Magento\Framework\Encryption\EncryptorInterface
In this way we can update customer password in Magento2.
Hope it will be helpful for you. 🙂