search
尋找貓咪~QQ 地點 桃園市桃園區 Taoyuan , Taoyuan

C# 能吻合 PHP 的MD5運算函數 – jashliao部落格

C# 能吻合 PHP 的MD5運算函數

 

 

        static public String MD5_BASE64forPHP(String StrData)
        {
            //https://stackoverflow.com/questions/5821677/md5-hashing-does-not-match-in-c-sharp-and-php
            //https://www.tools4noobs.com/online_php_functions/md5/
            //https://www.tools4noobs.com/online_php_functions/base64_encode/
            String StrAns = “”;
            byte[] asciiBytes = ASCIIEncoding.ASCII.GetBytes(StrData);
            byte[] hashedBytes = MD5CryptoServiceProvider.Create().ComputeHash(asciiBytes);
            string hashedString = BitConverter.ToString(hashedBytes).Replace(“-“, “”).ToLower();
            StrAns = Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(hashedString));//把加密後的字串從Byte[]轉為字串
            return StrAns;
        }



熱門推薦

本文由 jashliaoeuwordpress 提供 原文連結

寵物協尋 相信 終究能找到回家的路
寫了7763篇文章,獲得2次喜歡
留言回覆
回覆
精彩推薦