# Migrating users with password\_hash that have have cost of 12 rounds

**URL:** <https://community.auth0.com/t/migrating-users-with-password-hash-that-have-have-cost-of-12-rounds/54721>\
**Category:** Get Help\
**Tags:** login\
**Created:** [December 12, 2020, 12:45am UTC](https://community.auth0.com/t/migrating-users-with-password-hash-that-have-have-cost-of-12-rounds/54721 "2020-12-12T00:45:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![engineering4](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/engineering4/32/14208_2.png) [@engineering4](https://community.auth0.com/u/engineering4)\
**Post date:** [December 12, 2020, 12:45am UTC](https://community.auth0.com/t/migrating-users-with-password-hash-that-have-have-cost-of-12-rounds/54721/1 "2020-12-12T00:45:58Z")

</div>

Hi.. We have recently upgraded our bcrypt ruby gem which is why some of our passwords are encrypted with cost 12. Older passwords are cost 10

These newer passwords are failing your reg ex matching which means we can’t import more recent customers

eg.

$2a$12

prefix vs these that are fine

$2a$10

```
"errors": [
  {
    "code": "PATTERN",
    "message": "Error in passwordHash property - String does not match pattern ^\\$2[ab]?\\$10+\\$[./A-Za-z0-9]{53}$: $2a$12$2FiyJRDlILafg.46m623KOj5IN1Xa2G9sllzVbVoT3uKbpfaoBLHC",
    "path": "passwordHash"
  }
]

```

We tried and tested your migration process a couple of months ago with no issues. This issue has surfaced last minute so could really use some help getting this over the line. Do you not allow passwords with cost 12?

---

<div class="post-metadata">

**Author:** ![sidharth.chaudhary](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sidharth.chaudhary/32/20686_2.png) [@sidharth.chaudhary](https://community.auth0.com/u/sidharth.chaudhary)\
**Post date:** [December 12, 2020, 6:48am UTC](https://community.auth0.com/t/migrating-users-with-password-hash-that-have-have-cost-of-12-rounds/54721/2 "2020-12-12T06:48:04Z")

</div>

Hey @engineering4, Welcome to the Auth0 community!

I tested a bcrypt with 12 rounds , by importing a custom password hash for it, by the import/export extension and it seems to work correctly. It is supported there.

Generated the bcrypt from here:

> **[Bcrypt-Generator.com - Online Bcrypt Hash Generator & Checker](https://bcrypt-generator.com/)**
>
> Bcrypt-Generator.com is a online tool to check Bcrypt hashes. You can also use it to generate new Bcrypt hashes for your other applications that require a Bcrypt encrypted string or password

Then imported the following sample json payload using the import extension:

```
[
    {
            "user_id": "1207423456745",
            "email": "test@contoso.com",
            "custom_password_hash": {
                "algorithm": "bcrypt",
                "hash": {
                    "value": "$2y$12$FI9sV48tF.wWUVpE04Hauu97oPHs0nBvJICh6XZ1A01d8CSVH0YoG"
                }
            }
    }
]

```

More info:

> **[Bulk User Import Database Schema and Examples](https://auth0.com/docs/manage-users/user-migration/bulk-user-import-database-schema-and-examples)**
>
> Learn how to perform bulk user imports with the Management API.

After that I was able to login with the password.

Have a try and let me know!

Regards,  
Sid

---

<div class="post-metadata">

**Author:** ![engineering4](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/engineering4/32/14208_2.png) [@engineering4](https://community.auth0.com/u/engineering4)\
**Post date:** [December 12, 2020, 9:17pm UTC](https://community.auth0.com/t/migrating-users-with-password-hash-that-have-have-cost-of-12-rounds/54721/3 "2020-12-12T21:17:26Z")

</div>

Thanks for the quick reply. Great help. I was using just

```auto
"user_id": "1207423456745",
"email": "test@contoso.com",
"password_hash": "$2y$12$FI9sV48tF.wWUVpE04Hauu97oPHs0nBvJICh6XZ1A01d8CSVH0YoG"

```

I tried by both API and the extension but seeing this issue in both… You can see from the regular expression in the error message

^\$2[ab]?\$10+\$[./A-Za-z0-9]{53}

that it’s expecting the literal string

$10

Which is why I was worried.

Switching to use your payload structure and specifying bcrypt explicitly sorted this issue.

```auto
            "custom_password_hash": {
                "algorithm": "bcrypt",
                "hash": {
                    "value":

```

Thanks!!!

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [December 14, 2020, 9:46am UTC](https://community.auth0.com/t/migrating-users-with-password-hash-that-have-have-cost-of-12-rounds/54721/4 "2020-12-14T09:46:30Z")

</div>

Glad it’s working now and thanks for sharing it with the rest of community!

---

<div class="post-metadata">

**Author:** ![engineering4](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/engineering4/32/14208_2.png) [@engineering4](https://community.auth0.com/u/engineering4)\
**Post date:** [December 16, 2020, 6:06am UTC](https://community.auth0.com/t/migrating-users-with-password-hash-that-have-have-cost-of-12-rounds/54721/5 "2020-12-16T06:06:29Z")

</div>

![Screen Shot 2020-12-15 at 10.04.09 PM](https://global.discourse-cdn.com/auth0/original/3X/2/f/2fcbd95f7cdd48a149125ade57e1813a6afcc85f.png)

Just to share the documentation I missed in case anyone else comes across this.

Whoops

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [December 16, 2020, 1:58pm UTC](https://community.auth0.com/t/migrating-users-with-password-hash-that-have-have-cost-of-12-rounds/54721/6 "2020-12-16T13:58:43Z")

</div>

Thanks for sharing that with the rest of community!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [December 31, 2020, 1:58pm UTC](https://community.auth0.com/t/migrating-users-with-password-hash-that-have-have-cost-of-12-rounds/54721/7 "2020-12-31T13:58:49Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
