I appreciate Shubanshu's answer, but as srokatonie stated below it you should never edit files directly in vendor folder.
Instead, create a custom module with an app/code/{CustomModuleVendor}/{CustomModuleNamespace}/etc/di.xml
file in it with following content:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\Framework\Encryption\Encryptor" type="{CustomModuleVendor}\{CustomModuleNamespace}\Enrcyption\Encryptor" />
</config>
And the app/code/{CustomModuleVendor}/{CustomModuleNamespace}/Encryption/Encryptor.php
file:
<?php
namespace {CustomModuleVendor}\{CustomModuleNamespace}\Encryption;
class Encryptor extends \Magento\Framework\Encryption\Encryptor {
const HASH_VERSION_LATEST = "1";
protected $passwordHashMap = [
self::PASSWORD_HASH => '',
self::PASSWORD_SALT => '',
self::PASSWORD_VERSION => self::HASH_VERSION_LATEST
];
private $hashVersionMap = [
self::HASH_VERSION_MD5 => 'md5',
self::HASH_VERSION_SHA256 => 'sha256',
self::HASH_VERSION_ARGON2ID13 => 'md5'
];
/**
* @inheritdoc
*/
public function isValidHash($password, $hash)
{
try {
$this->explodePasswordHash($hash);
foreach ($this->getPasswordVersion() as $hashVersion) {
if ($hashVersion == '0') {
$recreated = current(explode(':', $hash));
}else if ($hashVersion === self::HASH_VERSION_ARGON2ID13) {
$recreated = $this->getArgonHash($password, $this->getPasswordSalt());
} else {
$recreated = $this->generateSimpleHash($this->getPasswordSalt() . $password, $hashVersion);
}
$hash = $this->getPasswordHash();
error_log('password changing technique ======');
error_log(print_r($recreated,true));
error_log(print_r($hash,true));
}
} catch (\RuntimeException $exception) {
//Hash is not a password hash.
$recreated = $this->hash($password);
}
return Security::compareStrings(
$recreated,
$hash
);
}
Make sure to replace all occurences of {CustomModuleVendor} {CustomModuleNamespace} with your module vendor and namespace.
This will use your class intance instead of the core one without changing vendor files (which would be lost when you update your magento framework).
More about using di.xml here