当前位置:网站首页>C one line code calculates the MD5 value of the file - codeplus series
C one line code calculates the MD5 value of the file - codeplus series
2022-07-01 09:54:00 【Great ape】
C# One line of code calculates the file's MD5 value
List of articles
Preface
MD5 Information digest algorithm ( English :MD5 Message-Digest Algorithm), A widely used cryptographic hash function , I can produce one 128 position (16 byte ) Hash value (hash value), Used to ensure complete and consistent transmission of information .
We often encounter calculation files in the process of development MD5 Scene . How to obtain one line of code simply and efficiently MD5 Is it worth it ? Let's have a look !
introduce CodePlus
Right click the item , choice management NuGet Package
Enter... In the search field CodePlus, After selecting the package in the figure , Select Install .
Sample code
obtain MD5 Byte array
var md5 = new FileInfo(@"D:\pic.png").GetMD5();
obtain MD5 character string
var md5 = new FileInfo(@"D:\pic.png").GetMD5().ToHexString();
obtain MD5 Other relevant methods
// To get a small file MD5
var md5 = new FileInfo(@"D:\pic.png").GetMD5ForSmallFile().ToHexString();
// Get large file MD5
var md5 = new FileInfo(@"D:\pic.png").GetMD5ForLargeFile().ToHexString();
// Automatic selection ( Greater than 10MB Will execute GetMD5ForLargeFile, Less than or equal to 10MB Will execute GetMD5ForSmallFile)
var md5 = new FileInfo(@"D:\pic.png").GetMD5().ToHexString();
边栏推荐
- Dspic30f6014a LCD block display
- [fxcg] large scale job hopping may be one of the driving forces behind the soaring inflation in the United States
- Strange, why is the ArrayList initialization capacity size 10?
- Change password of MySQL version 5.7 and 8.0
- Continue to advance, and softcom power steadily promotes cloud intelligence strategy
- Tryhackme Christmas challenge 2021 advance of cyber 3-day1-idor vulnerability, insecure access control vulnerability
- sql语句修改字段类型「建议收藏」
- 我喜欢两个男人。。。
- SQL学习笔记(02)——数据库表操作
- Comparison between Oracle JDK and openjdk
猜你喜欢
新数据库时代,不要只学 Oracle、MySQL
Swag init error: cannot find type definition: response Response
Huawei accounts work together at multiple ends to create a better internet life
The stock position building rate of global funds and asset management reached a new low in 15 years
Tearful eyes, it's not easy to change jobs. Three rounds of interviews, four hours of soul torture
日本教授起诉英特尔FPGA与SoC产品侵犯一项设计专利
历史上的今天:九十年代末的半导体大战;冯·诺依曼发表第一份草案;CBS 收购 CNET...
Meituan P4 carefully collated microservice system architecture design manual to see the world of microservice architecture
Flinkv1.13实现金融反诈骗案例
Fried money, lost 10million.
随机推荐
In terms of use
【leetcode】287. Find duplicates
Postgraduate entrance examination vocabulary 2023 sharing (1)
树莓派4B系统搭建(超详细版)
Ubuntu system installation and MySQL configuration
This is the best flash popular science article I have ever seen!
遇到女司机业余开滴滴,日入500!
富文本实现插值
The "China Mobile Chain" state secret engine was officially launched on BSN
年薪100万,在北上广深买的起房子吗?
直播管理项目
STM32逆变器电源设计方案,基于STM32F103控制器[通俗易懂]
架构实战营 模块九:设计电商秒杀系统
SQL learning notes (02) - database table operation
4hutool实战:DateUtil-格式化时间[通俗易懂]
121. thread scheduling: join() method and yield() method
What is cloud primordial? Will it be the trend of future development?
Fried money, lost 10million.
SQL learning notes (03) -- data constraint relationship
Common penetration tools -goby