[英]PHP MD5 hashing
i have a hashing algorithm in C#, in a nutshell, it is: 简而言之,我在C#中有一个哈希算法,它是:
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(code[i].ToString("x2"));
}
hashCode = stringBuilder.ToString();
}
return hashCode;
}
Now I need to replicate this behaviour in php..... Thanks in advance... 现在,我需要在php中复制此行为。
NOTE: I cannot change C# behaviour because it's already implemented and passwords saved in my db with this algorithm. 注意:我无法更改C#行为,因为它已经实现,并且使用此算法将密码保存在数据库中。
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? PHP内置了MD5功能,您可以放入任何内容并返回十六进制字符串,这是您的初衷吗?
md5() md5()
http://php.net/manual/en/function.md5.php http://php.net/manual/zh/function.md5.php
SEE BELOW 见下文
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.