Migrating users from a sha256 password

Hello,

passwords for our users were initially made using sha256_crypt.hash() in python resulting in following format : $5$rounds=535000$qgfr4.Ky9h/ODeTk$ByU6XFDg1UIUAboU/mOWP7v55h46x0hjdBHVQhaLtP4

Unfortunately the passwords do not match after importing users. The json contains the algorithm, hash and salt. Not sure though if the position of the salt is prefix,.

 "custom_password_hash": {
      "algorithm": "sha256",
      "hash": {
        "encoding": "base64",
        "value": "QnlVNlhGRGcxVUlVQWJvVS9tT1dQN3Y1NWg0NngwaGpkQkhWUWhhTHRQNA=="
      },
      "salt": {
        "position": "prefix",
        "value": "qgfr4.Ky9h/ODeTk"
      }
    },

Python code used to construct the json part:

            parts = original_password.split('$')
            password_bytes = parts[4].encode('ascii') #get the hash
            password_base64_bytes = base64.b64encode(password_bytes)
            password_data = password_base64_bytes.decode("ascii")

"custom_password_hash": {
                "algorithm": "sha256",
                "hash": {
                    "value": password_data,
                    "encoding": "base64"
                },
                "salt": {
                    "value": parts[3],
                    "position": "prefix"
                }
            }

Any help would be appreciated! Kind regards, Daniel

Hi @inspiran,

Welcome to the Auth0 Community!

I understand you are having trouble with a password hash import, I’ll look into it and get right back to you.

Thanks,
Dan

1 Like

What library are you using?

Hi Dan,

We are using
https://passlib.readthedocs.io/en/stable/lib/passlib.hash.sha256_crypt.html

encrypted_pwd = sha256_crypt.encrypt(plain_text_password)

1 Like

Any update on your findings Dan?

Hi @inspiran,

Apologies for the delay. I did a deep dive on this and discovered that you are limited to a max of 10k rounds for SHA256

If you don’t have those, then you will need to import users without hashes. Here’s a resource on that:

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