using System.Security.Cryptography;
string str = "20070111";
SHA1 sha1 = new SHA1CryptoServiceProvider();
byte[] bytes_sha1_in = UTF8Encoding.Default.GetBytes(str);
byte[] bytes_sha1_out = sha1.ComputeHash(bytes_sha1_in);
string str_sha1_out = BitConverter.ToString(bytes_sha1_out);
MessageBox.Show(str_sha1_out);
sha1加密(C# VS2005)(转自:http://yardan.blog.51cto.com/304821/60705)
SHA1哈希计算示例
最新推荐文章于 2023-03-22 10:22:06 发布
本文演示了如何使用C#中的System.Security.Cryptography命名空间来生成字符串'20070111'的SHA1哈希值。通过实例代码展示了从字符串到字节数组的转换过程,接着利用SHA1CryptoServiceProvider类计算哈希值,并最终将得到的字节序列转换为可读的字符串形式。
948

被折叠的 条评论
为什么被折叠?



