We are migrating customers from ERP to Magento 2.

In ERP passwords are in SHA-1 format while Magento does not support that.

We have 2 options - Either reset manually OR creation of a custom script to send the link to reset the password.

But I want to manage them directly. Do we have any way out where we can convert the passwords according to Magento standards and then proceed?

Please guide with solution


  • It possible if you adding support SHA-1 for Magento 2 ^^.
    – HoangHieu
    Commented Mar 23, 2022 at 13:03
  • @HoangHieu didn't get your answer Commented Mar 29, 2022 at 10:25
  • Let me define as an answer.
    – HoangHieu
    Commented Mar 29, 2022 at 12:56

2 Answers 2


The way to achieve this is you have to convert the password hash from SHA-1 to Magento supported Hash versions (MD5, SHA256, or Argon 2ID13).

You can take the reference from the link : how to convert M1 password hash to M2 password hash

In the Above they just use data migration tool to convert the password hash You can just modify hash constants in the controller script to achieve your goal.

Let me know if it works for you or not.

  • Sorry but this didn't work for me because I am migrating passwords from ERP to Magento. Your solution will work for M1->M2 Commented Mar 29, 2022 at 10:23
  • ok , I will dig more into it and update here Commented Mar 29, 2022 at 10:47
  • Perfect Thanks. Looking forward to hear from you Commented Mar 29, 2022 at 10:56

You can check the file vendor/magento/framework/Encryption/Encryptor.php:72, which defines the supported password hash version.

private $hashVersionMap = [
    self::HASH_VERSION_MD5 => 'md5',
    self::HASH_VERSION_SHA256 => 'sha256'

You could update that file with a composer patch or git patch. Here is my patch, after applying the patch you could update the customer password (Directly to MySQL) by pattern

Sample: hash = xxxxxxxxxx, salt: 123, version: 2
Result: xxxxxxxxxx:123:2
xxxxxxxxx: this is old hash value from your own ERP.
123: if the ERP has no salt, leave it empty xxxxxxxxxx::2

Now the Magento could validate the customer password using sha1 algorithm

Index: vendor/magento/framework/Encryption/Encryptor.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
diff --git a/vendor/magento/framework/Encryption/Encryptor.php b/vendor/magento/framework/Encryption/Encryptor.php
--- a/vendor/magento/framework/Encryption/Encryptor.php (date 1648559552172)
+++ b/vendor/magento/framework/Encryption/Encryptor.php (date 1648559552172)
@@ -23,7 +23,12 @@
      * Key of sha256 algorithm
     const HASH_VERSION_SHA256 = 1;
+    /**
+     * Key of sha-1 algorithm
+     */
+    const HASH_VERSION_SHA1 = 2;
      * Key of latest used algorithm
@@ -69,7 +74,8 @@
     private $hashVersionMap = [
         self::HASH_VERSION_MD5 => 'md5',
-        self::HASH_VERSION_SHA256 => 'sha256'
+        self::HASH_VERSION_SHA256 => 'sha256',
+        self::HASH_VERSION_SHA1 => 'sha1'
  • Hi, Thanks this seems to be useful. Let me try and confirm back Commented Mar 30, 2022 at 8:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.