当前位置:网站首页>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();
边栏推荐
- 架构实战营 模块九:设计电商秒杀系统
- UE small knowledge point controller possess pawn process
- Dspic30f6014a LCD block display
- Superscalar processor design yaoyongbin Chapter 4 branch prediction -- Excerpt from subsection 4.1
- SQL learning notes (04) - data update and query operations
- The market is relatively weak recently
- What is cloud primordial? Will it be the trend of future development?
- Rich text interpolation
- 新数据库时代,不要只学 Oracle、MySQL
- The latest masterpiece of Alibaba, which took 182 days to produce 1015 pages of distributed full stack manual, is so delicious
猜你喜欢

HMS core audio editing service 3D audio technology helps create an immersive auditory feast

Hololens2 development -6-eyetracking and speech recognition

Construction of esp8266 FreeRTOS development environment

项目必用的全局异常处理器,你学会了吗

炒币,亏了1000万。

Finally, someone made it clear what DRAM and NAND flash are

全球基金和资管的股票建仓率达到15年内新低

持续进阶,软通动力稳步推动云智能战略

7-Zip boycotted? The callers have committed "three crimes": pseudo open source, unsafe, and the author is from Russia!

This is the best flash popular science article I have ever seen!
随机推荐
怎么理解JS Promise
日本教授起诉英特尔FPGA与SoC产品侵犯一项设计专利
项目采购管理
我喜欢两个男人。。。
Sd-wan notes
Introduction to mt7628k eCos development
《天天数学》连载55:二月二十四日
Scratch big fish eat small fish Electronic Society graphical programming scratch grade examination level 2 true questions and answers analysis June 2022
Matrix and coordinates
Initial experience of Flink, a mainstream real-time stream processing computing framework
Live broadcast management project
What is cloud primordial? Will it be the trend of future development?
The stock position building rate of global funds and asset management reached a new low in 15 years
UE small knowledge point controller possess pawn process
微信表情符号写入判决书,你发的OK、炸弹都可能成为“呈堂证供”
Some tools used in embedded development
Construction of esp8266 FreeRTOS development environment
PO模式深入封装
数据中台咋就从“小甜甜”变成了“牛夫人”?
【leetcode】287. Find duplicates

