PHP MD5 hashing
i have a hashing algorithm in C#, in a nutshell, it is:
string hashCode = string.Empty;
if (null != password)
{
System.Security.Cryptography.MD5 cryptography = new System.Security.Cryptography.MD5CryptoServiceProvider();
byte[] code = cryptography.ComputeHash(Encoding.Default.GetBytes(password));
StringBuilder stringBuilder = new StringBuilder();
// Converting the code to string.
for (int i = 0; i < code.Length; i++)
{
stringBuilder.Append(cod开发者_开发百科e[i].ToString("x2"));
}
hashCode = stringBuilder.ToString();
}
return hashCode;
}
Now I need to replicate this behaviour in php..... Thanks in advance...
NOTE: I cannot change C# behaviour because it's already implemented and passwords saved in my db with this algorithm.
PHP has built in MD5 ability, you can put about anything in and get a hex string back, is this what you had in mind?
md5()
http://php.net/manual/en/function.md5.php
SEE BELOW
精彩评论