02
4

Mono for android中MD5加密的方法

0
归档:2013年4月分类:开源Mono
内容纲要

其实和C#的代码是一样的,完全可以复用,这里给出相应的代码

/// <summary>
/// MD5
/// </summary>
/// <param name="strText"></param>
/// <returns></returns>
public string MD5Hash(string strText)
{
MD5 MD5 = new MD5CryptoServiceProvider();
byte[] datSource = encoding.GetBytes(strText);
byte[] newSource = MD5.ComputeHash(datSource);
string byte2String = null;
for (int i = 0; i < newSource.Length; i++)
{
string thisByte = newSource[i].ToString("x");
if (thisByte.Length == 1) thisByte = "0" + thisByte;
byte2String += thisByte;
}
return byte2String.ToUpper();
}


声明: 本文采用 BY-NC-SA 协议进行授权. 未标注“转”的文章均为原创,转载请注明转自: Mono for android中MD5加密的方法

公告栏

欢迎大家来到我的博客,我是dodoro,希望我的博客能给你带来帮助。