# Bulk migration pbkdf2 can't login after successfull migration

**URL:** <https://community.auth0.com/t/bulk-migration-pbkdf2-cant-login-after-successfull-migration/188849>\
**Category:** Get Help\
**Tags:** users, management-api\
**Created:** [July 7, 2025, 4:44pm UTC](https://community.auth0.com/t/bulk-migration-pbkdf2-cant-login-after-successfull-migration/188849 "2025-07-07T16:44:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![luis4](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/luis4/32/71984_2.png) [@luis4](https://community.auth0.com/u/luis4)\
**Post date:** [July 7, 2025, 4:44pm UTC](https://community.auth0.com/t/bulk-migration-pbkdf2-cant-login-after-successfull-migration/188849/1 "2025-07-07T16:44:20Z")

</div>

I think I’m running into the same issue as this topic, which sadly don’t have a solution yet.

This doesn’t let me paste links but here’s the path of the similar post

```auto
/t/cant-log-in-using-imported-pbkdf2-hashed-passwords/61815

```

Here’s the code that originally created the salt and hash

```auto
async hashPassword(password: string) {
         const salt = crypto.randomBytes(16).toString('hex')
         const hash = crypto.pbkdf2Sync(password, salt, 100000, 64, 'sha256').toString('hex')
         return `${salt}:${hash}`
       }

```

This is the code I’m using to migrate

```auto
  const [saltHex, hashHex] = user.password.split(':')
  const saltBytes = Buffer.from(saltHex, 'hex')
  const hashBytes = Buffer.from(hashHex, 'hex')

  const saltB64 = saltBytes.toString('base64')
  const hashB64 = hashBytes.toString('base64')
    const hash2 = phc.serialize({
    id: 'pbkdf2-sha256',
    params: {
      i: 100000,
      l: 64
    },
    salt: Buffer.from(saltB64, 'base64'),
    hash: Buffer.from(hashB64, 'base64')
  })

  return {
    email: user.email,
    email_verified: true,
    given_name: user.additionalDetails?.firstName,
    family_name: user.additionalDetails?.lastName,
    picture: user.avatar,

    custom_password_hash: {
      algorithm: 'pbkdf2',
      hash: {
        encoding: 'utf8',
        value: hash2
      }
    }
  }

```

Also tried doing it manually but gets me the same result

```auto
  const hash = `$pbkdf2-sha256$i=100000,l=64$${saltB64.replaceAll('=', '')}$${hashB64.replaceAll('=', '')}`

```

Everything looks ok during the migration but when I try to login I see this in the dashboard’s logs

```auto
  "details": {
    "error": {
      "message": "Password change required.",
      "reason": "Verification failed for the provided custom_password_hash: {'algorithm':'pbkdf2','hash':{'encoding':'utf8','value':'$pbkdf2-sha256$QqblTgpBqA3jvDRl...'},'salt':{'value':''}}"
    }
  },

```

---

<div class="post-metadata">

**Author:** ![luis4](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/luis4/32/71984_2.png) [@luis4](https://community.auth0.com/u/luis4)\
**Post date:** [July 7, 2025, 5:57pm UTC](https://community.auth0.com/t/bulk-migration-pbkdf2-cant-login-after-successfull-migration/188849/2 "2025-07-07T17:57:58Z")

</div>

Figured it out.

Since originally the salt passed to crypto.pbkdf2Sync came from

```auto
         const salt = crypto.randomBytes(16).toString('hex')

```

I had to create the buffer from ascii instead of hex

```auto
  const saltBytes = Buffer.from(saltHex, 'ascii')

```

With this change the passwords started matching

---

<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:** [July 21, 2025, 5:58pm UTC](https://community.auth0.com/t/bulk-migration-pbkdf2-cant-login-after-successfull-migration/188849/3 "2025-07-21T17:58:26Z")

</div>

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