Knight
Knight

Reputation: 514

convert .net password hasing function to PHP

I have this function in .net

public static byte[] EncryptPassword(string username, string pwd, string salt)
{
    string toHash = username + salt + pwd;

    UTF8Encoding textConverter = new UTF8Encoding();
    byte[] passBytes = textConverter.GetBytes(toHash);
    byte[] thePassword = new SHA384Managed().ComputeHash(passBytes);

    return thePassword;
}

and trying to convert it into php

function EncryptPassword($username, $pwd, $salt)
{
    $hash = $username.$salt.$pwd;
    return hash('sha384',$hash);
}

but I m unable to get the same password hash,any help ?

Upvotes: 1

Views: 102

Answers (1)

Hektor
Hektor

Reputation: 1945

Well you're using $password inside the function, but passing $pwd as an argument.

Upvotes: 3

Related Questions