Importing users with hashed passwords into OKTA

My aim is to import existing users into OKTA (and keep their passwords same as before). I am using this python code from Okta developer website to create the hashed password (see below):

import hashlib
import base64
import json

password = “test password”

hashed = hashlib.sha1(bytes(password, ‘utf-8’))
result = {
“algorithm”: “SHA-1”,
“value”: base64.b64encode(hashed.digest()).decode(“ascii”),
}
print(json.dumps(result, indent=4))

After this, I am using the OKTA API call to test and create my test user but i cannot seem to login with the password set in this process.

Even with using the examples from the developer website exactly the same, I still cannot make it work. Wondering if something is wrong with the example code or am i missing something ?

Thanks so much for the help, in advance !

Hello,
I assume you are following this sample https://developer.okta.com/blog/2021/03/05/ultimate-guide-to-password-hashing-in-okta#hash-only-1?
If so can you supply the entire API import command you use to import the user into Okta.

If I use,

curl --location --request POST 'https://{ORG}.okta.com/api/v1/users?activate=true' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: SSWS {API_TOKEN}' \
--data-raw '{
  "profile": {
    "firstName": "Hashed",
    "lastName": "Pass",
    "email": "hash@pass.com",
    "login": "hash@pass.com"
  },
  "credentials": {
    "password" : {
      "hash": {
        "algorithm": "SHA-1",
        "value": "LOsCqF9tTebCiy5Z/aiG1Sba+w0="
      }
    }
  }
}'

I am able to login fine using,
user: hash@pass.com
pass: ‘test password’

I have similar issue, hope it’s fine to add it here instead of creating a new post.

My passwords are generated by PHP crypt function using SHA-512 algorithm.

$salt = '$6$rounds=1000$' . 'my-salt' . '$';
$password = crypt('my-password', $salt)

I read The Ultimate Guide to Password Hashing in Okta | Okta Developer and Users | Okta Developer , but I still cannot login to Okta using my passwords. This is my code:

return [
        'algorithm' => 'SHA-512',
        'saltOrder' => 'PREFIX',
        'salt' => base64_encode($salt),
        'value' => base64_encode($password),
    ];

Any help is much appreciated.