相对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 算法实现代码
猜你喜欢
- Oracle中for循环的使用方法 2023-07-04
- WPF使用DrawingContext实现绘制刻度条 2023-07-04
- 在C# 8中如何使用默认接口方法详解 2023-03-29
- 如何使用C# 捕获进程输出 2023-03-10
- c# 模拟线性回归的示例 2023-03-14
- Unity Shader实现模糊效果 2023-04-27
- user32.dll 函数说明小结 2022-12-26
- Unity3D实现渐变颜色效果 2023-01-16
- .NET CORE DI 依赖注入 2023-09-27
- C# 使用Aspose.Cells 导出Excel的步骤及问题记录 2023-05-16