原创:MD5加密函数(C#)

ChenReal

MD5是一组不能逆转(非对称的没有反函数)的加密方式,所以验证的时候也只能是加密后跟原密码相比较,符合则通过。前些日子查了些资料,VBS的MD5代码足足有300多行。如果用在.NET上就方便多了,利用内置的对象,寥寥几行代码便可实现MD5加密了!!\n\ncsharp\nstring myMD5(string inputstring)\n {\n System.Security.Cryptography.MD5 md = new System.Security.Cryptography.MD5CryptoServiceProvider();\n byte[] inputdata = System.Text.ASCIIEncoding.ASCII.GetBytes(inputstring);\n byte[] outputdata =md.ComputeHash(inputdata);\n string re = \"\";\n for (int i=0 ;i<16 ;i++)\n {\n re += System.Convert.ToString(outputdata[i],16);\n }\n return re;\n }\n\n\n