[英]Diffrent result of md5 between php and c#
您好,我試圖將此零件代碼從php轉換為c#,結果相同:
PHP的 :
md5("apple", true) //result :8pѕ'OlIігg(•
C# :
byte[] asciiBytes = ASCIIEncoding.ASCII.GetBytes("apple");
byte[] hashedBytes = MD5CryptoServiceProvider.Create().ComputeHash(asciiBytes);
return System.Text.Encoding.ASCII.GetString(hashedBytes); //result: 8p?'OlI??g(?
相似但不完全相同
更新:使用BitConverter.ToString(hashedBytes).Replace("-", "").ToLower();
我有:1f3870be274f6c49b3e31a0c6728957f
而且當我使用md5(“ apple”,false)時我沒有任何問題
嘗試這個:
var md5 = System.Security.Cryptography.MD5.Create();
byte[] inputBytes = Encoding.Default.GetBytes(input);
byte[] hash = md5.ComputeHash(inputBytes);
var s = Encoding.Default.GetString(hash);
或選擇其他編碼格式。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.