# ASP.NET membership Import not working

**URL:** <https://community.auth0.com/t/asp-net-membership-import-not-working/67437>\
**Category:** Get Help\
**Tags:** aspnet-mvc, sha1, user-import\
**Created:** [August 5, 2021, 2:12pm UTC](https://community.auth0.com/t/asp-net-membership-import-not-working/67437 "2021-08-05T14:12:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MartijnZ](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/martijnz/32/25477_2.png) [@MartijnZ](https://community.auth0.com/u/MartijnZ)\
**Post date:** [August 5, 2021, 2:12pm UTC](https://community.auth0.com/t/asp-net-membership-import-not-working/67437/1 "2021-08-05T14:12:07Z")

</div>

Hi,

I am running into this issue using an old [ASP.NET](http://ASP.NET) project using Membership.  
It has the password hashed with sha1 in the database and salt in the dbo.Membership table.

When trying to import an example using the user-import-export extension it still fails for some reason.

```auto
[{
    "user_id": "12345",
    "email": "test@example.com",
    "email_verified": true,
    "custom_password_hash": {
        "algorithm": "sha1",
        "hash": {
            "value": "Bc0bbM6qEy5ymgnruvTUuNhnVKU=",
            "encoding": "base64"
        },
        "salt": {
            "value": "oVZDJPuCI5xuQ8k0jOeblQ==",
            "position": "prefix",
            "encoding": "base64"
        },
        "password": {
            "encoding": "utf8"
        }
    }
}]

```

I could simple use the following c# code to verify that it works using SHA1.

```auto
public static void Main()
{
	var encoded = EncodePassword("testing", "oVZDJPuCI5xuQ8k0jOeblQ==");
	Console.WriteLine(encoded); // result output "Bc0bbM6qEy5ymgnruvTUuNhnVKU="
}
public static string EncodePassword(string pass, string salt)
{
	byte[] bytes = Encoding.Unicode.GetBytes(pass);
      byte[] numArray1 = Convert.FromBase64String(salt);

	var hashAlgorithm = HashAlgorithm.Create("SHA1");
	var buffer = new byte[numArray1.Length + bytes.Length];
       Buffer.BlockCopy(numArray1, 0, buffer, 0, numArray1.Length);
       Buffer.BlockCopy(bytes, 0, buffer, numArray1.Length, bytes.Length);
       var inArray = hashAlgorithm.ComputeHash(buffer);

	return Convert.ToBase64String(inArray);
}	

```

yet when trying to configure the custom\_password\_hash using sha1 it imports correctly but the password “testing” fails when trying it out.

Am i missing a value anywhere or some decoding/encoding issue i forgot ?

---

<div class="post-metadata">

**Author:** ![MartijnZ](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/martijnz/32/25477_2.png) [@MartijnZ](https://community.auth0.com/u/MartijnZ)\
**Post date:** [August 6, 2021, 12:03pm UTC](https://community.auth0.com/t/asp-net-membership-import-not-working/67437/2 "2021-08-06T12:03:55Z")

</div>

Resolved: i was using the wrong password encoding, since my c# example was Unicode i had to change it to use “utf16le” instead of utf-8.

```auto
"password": {
     "encoding": "utf16le"
}

```

🔨 😄

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [August 6, 2021, 12:15pm UTC](https://community.auth0.com/t/asp-net-membership-import-not-working/67437/3 "2021-08-06T12:15:35Z")

</div>

Wohooo! Glad you have figured it out and thanks for sharing with the rest of community!

---

<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:** [August 21, 2021, 12:16pm UTC](https://community.auth0.com/t/asp-net-membership-import-not-working/67437/4 "2021-08-21T12:16:03Z")

</div>

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