# Import user with custom password hash

**URL:** <https://community.auth0.com/t/import-user-with-custom-password-hash/103431>\
**Category:** Get Help\
**Tags:** user-import-export, user-management\
**Created:** [March 27, 2023, 5:05pm UTC](https://community.auth0.com/t/import-user-with-custom-password-hash/103431 "2023-03-27T17:05:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cjones](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@cjones](https://community.auth0.com/u/cjones)\
**Post date:** [March 27, 2023, 5:05pm UTC](https://community.auth0.com/t/import-user-with-custom-password-hash/103431/1 "2023-03-27T17:05:11Z")

</div>

I’ve imported a user with a custom password hash. There are no errors, but when I attempt to log in to Auth0 with the user’s password, the login fails and this message appears in the Auth0 logs:

```auto
 {
  "date": "2023-03-27T15:50:56.200Z",
  "type": "fp",
  "description": "Password change required.",
  "connection": "Username-Password-Authentication",
  "connection_id": "con_AFgPRyO4FnWb3N5Y",
  "client_id": "UKPTkTvlq8B6tQRbtwRSTZrOCenqxwmE",
  "client_name": "All Applications",
  "ip": "2600:1702:3870:7140:6860:d079:da:6b",
  "user_agent": "Chrome 111.0.0 / Windows 10.0.0",
  "details": {
    "error": {
      "message": "Password change required.",
      "reason": "Verification failed for the provided custom_password_hash: {'algorithm':'sha1','hash':{'value':'c32c737848...','encoding':'hex'},'salt':{'value':'87c11281...','encoding':'hex','position':'suffix'}}"
    }
  },
  "user_id": "auth0|foo",
  "user_name": "foo@bar.com",
  "strategy": "auth0",
  "strategy_type": "database",
  "log_id": "90020230327155100400915000000000000001223372036991371193",
  "_id": "90020230327155100400915000000000000001223372036991371193",
  "isMobile": false,
  "id": "90020230327155100400915000000000000001223372036991371193"
}

```

The JSON file containing this user looks like this:

```auto
[
    {
        "email":"foo@bar.com",
        "email_verified":true,
        "user_id":"foo",
        "given_name": "foo given name",
        "family_name": "bar family name",
        "name": "foo j. bar",
        "nickname": "nick foo",
        "blocked": false,
        "custom_password_hash": {
            "algorithm": "sha1",
            "hash": {
                "value": "c32c7378....c47536f3a4",
                "encoding": "hex"
            },
            "salt": {
                "value": "87c112810....9b62611627813",
                "encoding": "hex",
                "position": "suffix"
            }
        }
    }
]

```

the Python code that generated the hash and salt is as follows:  
pass\_salt = uuid.uuid4().hex  
pass\_hashed = hashlib.sha1((new\_pass + pass\_salt).encode(‘utf-8’)).hexdigest()

Can anyone tell me if there’s something I can change in the way I import a user to make this salt and hash scheme to work?

Thanks, Chris

---

<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:** [March 30, 2023, 4:32pm UTC](https://community.auth0.com/t/import-user-with-custom-password-hash/103431/3 "2023-03-30T16:32:23Z")

</div>

Hi @cjones,

Welcome to the Auth0 Community!

Can you please provide an example password, salt, and matching hash for testing? I’d like to try and import a user and see if I can get it working.

Thanks,  
Dan

---

<div class="post-metadata">

**Author:** ![cjones](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@cjones](https://community.auth0.com/u/cjones)\
**Post date:** [March 31, 2023, 6:54pm UTC](https://community.auth0.com/t/import-user-with-custom-password-hash/103431/4 "2023-03-31T18:54:27Z")

</div>

> [@cjones](#):
>
> ```auto
> "connection": "Username-Password-Authentication",
> 
> ```

Thanks Dan, I just got this working based on a suggestion from Lihua Zhang. The solution was to remove the line “encoding”: “hex” from the HASH. it turns out that uuid4.hex doesn’t mean hex encoded.

---

<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:** [May 1, 2023, 1:43pm UTC](https://community.auth0.com/t/import-user-with-custom-password-hash/103431/5 "2023-05-01T13:43:49Z")

</div>

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