# User\_id hash on Custom DB

**URL:** <https://community.auth0.com/t/user-id-hash-on-custom-db/6333>\
**Category:** Get Help\
**Tags:** user\_id, hash, custom-database\
**Created:** [April 24, 2017, 1:11pm UTC](https://community.auth0.com/t/user-id-hash-on-custom-db/6333 "2017-04-24T13:11:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![maziar](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@maziar](https://community.auth0.com/u/maziar)\
**Post date:** [April 24, 2017, 1:11pm UTC](https://community.auth0.com/t/user-id-hash-on-custom-db/6333/1 "2017-04-24T13:11:39Z")

</div>

I am moving my users on-premises and was wondering which type of hashing auth0 is using when running on the local DB?

---

<div class="post-metadata">

**Author:** ![prashantT](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/prashantt/32/6002_2.png) [@prashantT](https://community.auth0.com/u/prashantT)\
**Post date:** [April 24, 2017, 2:20pm UTC](https://community.auth0.com/t/user-id-hash-on-custom-db/6333/2 "2017-04-24T14:20:07Z")

</div>

I don’t quite understand your question - what do you mean by `when running on the local DB`? The Auth0 user\_id is simply an internal identifier that consists of a connection name and a unique identifier for the user.

---

<div class="post-metadata">

**Author:** ![maziar](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@maziar](https://community.auth0.com/u/maziar)\
**Post date:** [April 24, 2017, 2:23pm UTC](https://community.auth0.com/t/user-id-hash-on-custom-db/6333/3 "2017-04-24T14:23:44Z")

</div>

By local DB i mean running the DB inside auth0 and not CustomDB. The ID are hashed on auth0 while on my own database its a simple PK starting from 1…x. I would like to re-create the same hashing behaviour on my PK.

---

<div class="post-metadata">

**Author:** ![prashantT](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/prashantt/32/6002_2.png) [@prashantT](https://community.auth0.com/u/prashantT)\
**Post date:** [April 24, 2017, 2:50pm UTC](https://community.auth0.com/t/user-id-hash-on-custom-db/6333/4 "2017-04-24T14:50:54Z")

</div>

To retain the id from your custom db, you can return that id in the user profile in your custom db scripts, e.g:

```
 callback(null, {
        user_id: user.id // user.id is the PK in my custom db
      });

```

---

<div class="post-metadata">

**Author:** ![prashantT](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/prashantt/32/6002_2.png) [@prashantT](https://community.auth0.com/u/prashantT)\
**Post date:** [April 24, 2017, 2:50pm UTC](https://community.auth0.com/t/user-id-hash-on-custom-db/6333/5 "2017-04-24T14:50:54Z")

</div>

To retain the id from your custom db, you can return that id in the user profile in your custom db scripts, e.g:

```
 callback(null, {
        user_id: user.id // user.id is the PK in my custom db
      });

```

---

<div class="post-metadata">

**Author:** ![maziar](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@maziar](https://community.auth0.com/u/maziar)\
**Post date:** [April 24, 2017, 3:02pm UTC](https://community.auth0.com/t/user-id-hash-on-custom-db/6333/6 "2017-04-24T15:02:52Z")

</div>

Thanks. But this does not explain which type of hashing auth0 is using? I want to implement the same hash function on my CustomDB…

---

<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:** [March 2, 2018, 5:53am UTC](https://community.auth0.com/t/user-id-hash-on-custom-db/6333/7 "2018-03-02T05:53:27Z")

</div>


