簡體   English   中英

PHP MD5哈希

[英]PHP MD5 hashing

簡而言之,我在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;
    }

現在,我需要在php中復制此行為。

注意:我無法更改C#行為,因為它已經實現,並且使用此算法將密碼保存在數據庫中。

PHP內置了MD5功能,您可以放入任何內容並返回十六進制字符串,這是您的初衷嗎?

md5()

http://php.net/manual/zh/function.md5.php

見下文

PHP中的加密

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM