# Migration of users (bulk import) with pbkdf2 - not working - encoding not clear

**URL:** <https://community.auth0.com/t/migration-of-users-bulk-import-with-pbkdf2-not-working-encoding-not-clear/119096>\
**Category:** Get Help\
**Tags:** automatic-migration, user-management\
**Created:** [October 22, 2023, 10:00am UTC](https://community.auth0.com/t/migration-of-users-bulk-import-with-pbkdf2-not-working-encoding-not-clear/119096 "2023-10-22T10:00:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![noamb](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/noamb/32/51867_2.png) [@noamb](https://community.auth0.com/u/noamb)\
**Post date:** [October 22, 2023, 10:00am UTC](https://community.auth0.com/t/migration-of-users-bulk-import-with-pbkdf2-not-working-encoding-not-clear/119096/1 "2023-10-22T10:00:57Z")

</div>

I am trying to bulk import and check that the pbkdf2 password works but it doesn’t  
passworkd = ‘12345678’ salt = ‘TUN0EKuE’ (binary ascii) iterations=150000, keyl=64

our db saves it as “$pbkdf2-sha256$i=150000$TUN0EKuE$4dfeab07c9972d63a113b834e058467ecf0a0a0c80963f02937beec8cf3382b0”

(i’ve check via code, and 2 websites the hash is the correct hex value)

but after import, login fails with wrong password (and need to change because it can’t verify a custom hash)

```auto
  "details": {
    "error": {
      "message": "Password change required.",
      "reason": "Verification failed for the provided custom_password_hash: {'algorithm':'pbkdf2','hash':{'value':'$pbkdf2-sha256$i=150000,l=64$TU...'},'salt':{'value':''}}"
    }
  },

```

i have imported 12 versions of this :  
salt as binary (ascii), salt as hex string of binary, salt as base64 of binary and salt as base64 of the hex string of the binary  
hash as hex string, hash as base64 of binary value, and hash as base64 of hex string  
(4 salts time 3 hashes)  
the following:

```auto
$pbkdf2-sha256$i=150000,l=64$TUN0EKuE$4dfeab07c9972d63a113b834e058467ecf0a0a0c80963f02937beec8cf3382b0
$pbkdf2-sha256$i=150000,l=64$TUN0EKuE$Tf6rB8mXLWOhE7g04FhGfs8KCgyAlj8Ck3vuyM8zgrA
$pbkdf2-sha256$i=150000,l=64$TUN0EKuE$NGRmZWFiMDdjOTk3MmQ2M2ExMTNiODM0ZTA1ODQ2N2VjZjBhMGEwYzgwOTYzZjAyOTM3YmVlYzhjZjMzODJiMA
$pbkdf2-sha256$i=150000,l=64$54554e30454b7545$4dfeab07c9972d63a113b834e058467ecf0a0a0c80963f02937beec8cf3382b0
$pbkdf2-sha256$i=150000,l=64$54554e30454b7545$Tf6rB8mXLWOhE7g04FhGfs8KCgyAlj8Ck3vuyM8zgrA
$pbkdf2-sha256$i=150000,l=64$54554e30454b7545$NGRmZWFiMDdjOTk3MmQ2M2ExMTNiODM0ZTA1ODQ2N2VjZjBhMGEwYzgwOTYzZjAyOTM3YmVlYzhjZjMzODJiMA
$pbkdf2-sha256$i=150000,l=64$VFVOMEVLdUU$4dfeab07c9972d63a113b834e058467ecf0a0a0c80963f02937beec8cf3382b0
$pbkdf2-sha256$i=150000,l=64$VFVOMEVLdUU$Tf6rB8mXLWOhE7g04FhGfs8KCgyAlj8Ck3vuyM8zgrA
$pbkdf2-sha256$i=150000,l=64$VFVOMEVLdUU$NGRmZWFiMDdjOTk3MmQ2M2ExMTNiODM0ZTA1ODQ2N2VjZjBhMGEwYzgwOTYzZjAyOTM3YmVlYzhjZjMzODJiMA
$pbkdf2-sha256$i=150000,l=64$NTQ1NTRlMzA0NTRiNzU0NQo$4dfeab07c9972d63a113b834e058467ecf0a0a0c80963f02937beec8cf3382b0
$pbkdf2-sha256$i=150000,l=64$NTQ1NTRlMzA0NTRiNzU0NQo$Tf6rB8mXLWOhE7g04FhGfs8KCgyAlj8Ck3vuyM8zgrA
$pbkdf2-sha256$i=150000,l=64$NTQ1NTRlMzA0NTRiNzU0NQo$NGRmZWFiMDdjOTk3MmQ2M2ExMTNiODM0ZTA1ODQ2N2VjZjBhMGEwYzgwOTYzZjAyOTM3YmVlYzhjZjMzODJiMA

```

I am looking for ideas on what i’m doing wrong ?

Help is appeciated

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [October 26, 2023, 8:10pm UTC](https://community.auth0.com/t/migration-of-users-bulk-import-with-pbkdf2-not-working-encoding-not-clear/119096/3 "2023-10-26T20:10:06Z")

</div>

Hi @noamb,

Welcome to the Auth0 Community!

Thanks for sharing the relevant info. Can you please provide an example user import json?

---

<div class="post-metadata">

**Author:** ![noamb](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/noamb/32/51867_2.png) [@noamb](https://community.auth0.com/u/noamb)\
**Post date:** [October 29, 2023, 8:09am UTC](https://community.auth0.com/t/migration-of-users-bulk-import-with-pbkdf2-not-working-encoding-not-clear/119096/4 "2023-10-29T08:09:31Z")

</div>

```
{
    "email": "noam.berg31@gmail.com",
    "email_verified": true,
    "custom_password_hash": {
        "algorithm": "pbkdf2",
        "hash": {
            "value": "$pbkdf2-sha256$i=150000,l=64$TUN0EKuE$Tf6rB8mXLWOhE7g04FhGfs8KCgyAlj8Ck3vuyM8zgrA"
        }
    },
    "app_metadata": {
        "exp": "salt is binary (ascii), hash is binary as base64",
        "at_bay_user_id": "0c75e1df-fb1f-462a-91bb-9076874e860b",
        "version": 1,
        "imported": true,
        "user_type": "BP_USER"
    },
    "given_name": "Noam Test BP",
    "family_name": "Berg Test BP"
},

```

---

<div class="post-metadata">

**Author:** ![noamb](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/noamb/32/51867_2.png) [@noamb](https://community.auth0.com/u/noamb)\
**Post date:** [November 1, 2023, 1:22pm UTC](https://community.auth0.com/t/migration-of-users-bulk-import-with-pbkdf2-not-working-encoding-not-clear/119096/5 "2023-11-01T13:22:01Z")

</div>

We found the issue:

1. both salt and hash need to be a base64 (without padding) of the binary datas
2. our original creation of the hash was done with python hashlib.pbkdf2\_hmac it seems that the default keylen is 32 (and not 64 as we thought)

also an online tool we used to verify our code seems to have a bug because it asks for keylen and when given 64 it generated 64 hex string (=32 bytes) so it fooled us to think our keylen was 64.

“$pbkdf2-sha512$i=150000,l=32$VFVOMEVLdUU$Tf6rB8mXLWOhE7g04FhGfs8KCgyAlj8Ck3vuyM8zgrA”  
this is the correct hash value (original password is 12345678 )

I am posting this in hopes it will help someone in the future

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [November 3, 2023, 2:58pm UTC](https://community.auth0.com/t/migration-of-users-bulk-import-with-pbkdf2-not-working-encoding-not-clear/119096/6 "2023-11-03T14:58:59Z")

</div>

Thanks for following up with a solution @noamb! Very helpful.

---

<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:** [November 17, 2023, 2:59pm UTC](https://community.auth0.com/t/migration-of-users-bulk-import-with-pbkdf2-not-working-encoding-not-clear/119096/7 "2023-11-17T14:59:11Z")

</div>

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