相对C#来说,md5算法就相对简单很多,因为 System.Security.Cryptography; 已经包含了md5算法。所以我们只需创建MD5类对象即可实现md5算法,今天通过本文给大家介绍C# md5 算法实现,感兴趣的朋友一起看看吧
MD5的全称是message-digest algorithm 5 信息-摘要算法,在90年代初由mit laboratory
for computer science和rsa data security inc的ronald l. rivest开发出来。
相对C#来说,md5算法就相对简单很多,因为 System.Security.Cryptography; 已经包含了md5算法。所以我们只需创建MD5类对象即可实现md5算法。下面举例说明:
例子:输入任意字符,打印出md5计算结果(16进制输出)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Security.Cryptography;
namespace md5
{
class Program
{
static void Main(string[] args)
{
MD5 md5 = new MD5CryptoServiceProvider();
string str = Console.ReadLine();
byte[] data = Encoding.UTF8.GetBytes(str);
byte[] result = md5.ComputeHash(data);
for (int i = 0; i < 16; i++)
{
Console.Write(result[i].ToString("X2"));
Console.Write(" ");
}
Console.ReadKey();
}
}
}
到此这篇关于C# md5 算法实现代码的文章就介绍到这了,更多相关C# md5 算法内容请搜索得得之家以前的文章希望大家以后多多支持得得之家!
织梦狗教程
本文标题为:C# md5 算法实现代码


基础教程推荐
猜你喜欢
- 实例详解C#实现http不同方法的请求 2022-12-26
- C# 解析XML和反序列化的示例 2023-04-14
- Unity shader实现高斯模糊效果 2023-01-16
- C#通过标签软件Bartender的ZPL命令打印条码 2023-05-16
- C#获取指定目录下某种格式文件集并备份到指定文件夹 2023-05-30
- c# – USING块在网站与Windows窗体中的行为不同 2023-09-20
- C#中 Json 序列化去掉null值的方法 2022-11-18
- C#调用摄像头实现拍照功能的示例代码 2023-03-09
- Unity 如何获取鼠标停留位置下的物体 2023-04-10
- C#中的Linq to JSON操作详解 2023-06-08