0

I want to compare hash created with OracleMembershipProvider method:

CreateUser(username, password, e-mail) 

with hash manually created in php. CreateUser method saves password hash and salt in db. I must add that salt values are different for each password.

I dont know th pattern that OracleMembershipProvider is using for hash generating. since my .NET application is 4.5 framework and hash algorithmtype is not specified I presume sha-1 is used.

I just want to get pattern of hash generation so I can compare it and use the same db for PHP application log in.

Thank you in advance.

Azoro
  • 391
  • 3
  • 7

1 Answers1

1

I finnally found an answer:

password generation with OracleMembershipProvider is the same as in SQLMembershipProvider. so this question has the same answer as here: What is default hash algorithm that ASP.NET membership uses?

this function works OK for me.

public string EncodePassword(string pass, string salt)
        {
            byte[] bytes = Encoding.Unicode.GetBytes(pass);
            //byte[] src = Encoding.Unicode.GetBytes(salt); Corrected 5/15/2013
            byte[] src = Convert.FromBase64String(salt);
            byte[] dst = new byte[src.Length + bytes.Length];
            Buffer.BlockCopy(src, 0, dst, 0, src.Length);
            Buffer.BlockCopy(bytes, 0, dst, src.Length, bytes.Length);
            HashAlgorithm algorithm = HashAlgorithm.Create("SHA1");
            byte[] inArray = algorithm.ComputeHash(dst);
            return Convert.ToBase64String(inArray);
        }

Edit: All i had to do is to convert this code into PHP. I found this conversion: Trying to port C# function to PHP5

Community
  • 1
  • 1
Azoro
  • 391
  • 3
  • 7