https://www.cnblogs.com/xiaochu/p/4402195.html
MD5加密字符串并转化为base64(C#和PHP代码相同实现)
-------PHP------代码------------- function Md5Base64($data) { $md5hex=md5($data); $len=strlen($md5hex)/2; $md5raw=""; for($i=0;$i<$len;$i++) { $md5raw=$md5raw . chr(hexdec(substr($md5hex,$i*2,2))); }
$keyMd5=base64_encode($md5raw);
return $keyMd5; }
---------C#=----------------------
public static string MD5ToBase64String(string str) { MD5 md5 = new MD5CryptoServiceProvider(); byte[] MD5 = md5.ComputeHash(System.Text.Encoding.UTF8.GetBytes(str));//MD5(注意UTF8编码) string result = Convert.ToBase64String(MD5, 0, MD5.Length);//Base64 return result; }
https://www.cnblogs.com/xiaochu/p/4402195.html
MD5加密字符串并转化为base64(C#和PHP代码相同实现)
-------PHP------代码------------- function Md5Base64($data) { $md5hex=md5($data); $len=strlen($md5hex)/2; $md5raw=""; for($i=0;$i<$len;$i++) { $md5raw=$md5raw . chr(hexdec(substr($md5hex,$i*2,2))); }
$keyMd5=base64_encode($md5raw);
return $keyMd5; }
---------C#=----------------------
public static string MD5ToBase64String(string str) { MD5 md5 = new MD5CryptoServiceProvider(); byte[] MD5 = md5.ComputeHash(System.Text.Encoding.UTF8.GetBytes(str));//MD5(注意UTF8编码) string result = Convert.ToBase64String(MD5, 0, MD5.Length);//Base64 return result; }
|
请发表评论