本文实例讲述了c#实现的字符串转md5码函数。分享给大家供大家参考,具体如下:
/* 测试环境:winxp sp3、visual studio 2008 sp1、visual studio 2010 sp1 更新日期:2014-04-23 */ public string calculatemd5hash(string input) { md5 md5 = system.security.cryptography.md5.create(); byte[] inputbytes = system.text.encoding.utf8.getbytes(input); byte[] hash = md5.computehash(inputbytes); // step 2, convert byte array to hex string stringbuilder sb = new stringbuilder(); for (int i = 0; i < hash.length; i++) { sb.append(hash[i].tostring("x2")); } return sb.tostring(); }//end func
更多关于c#相关内容感兴趣的读者可查看本站专题:《c#字符串操作技巧总结》、《c#程序设计之线程使用技巧总结》、《c#操作excel技巧总结》、《c#中xml文件操作技巧汇总》、《c#常见控件用法教程》、《winform控件用法总结》、《c#数据结构与算法教程》、《c#数组操作技巧总结》及《c#面向对象程序设计入门教程》
希望本文所述对大家c#程序设计有所帮助。
如对本文有疑问, 点击进行留言回复!!
使用Visual Studio2019创建C#项目(窗体应用程序、控制台应用程序、Web应用程序)
C#实现获取本地内网(局域网)和外网(公网)IP地址的方法分析
网友评论