开发者

PHP MD5 hashing

开发者 https://www.devze.com 2023-02-16 17:07 出处:网络
i have a hashing algorithm in C#, in a nutshell, it is: string hashCode = string.Empty; if (null != password)

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

PHP MD5 hashing

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号