文件CRC和MD5校验
生活随笔
收集整理的這篇文章主要介紹了
文件CRC和MD5校验
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
文件CRC和MD5校驗
CRC和MD5用于文件和數據的傳輸校驗,以確認是否接收成功。
unit CRCMD5;interface { 獲取文件CRC校驗碼 } function GetFileCRC(const iFileName: string): String; { 獲取字符串CRC校驗碼 } function GetStringCRC(const Str: string): Cardinal; { 取文件MD5碼 } function GetFileMD5(const iFileName: string): String;implementationuses Classes, IdHashMessageDigest, IdHashCRC;{ 獲取文件CRC校驗碼 } function GetFileCRC(const iFileName: string): String; varMemSteam: TMemoryStream;MyCRC : TIdHashCRC32; beginMemSteam := TMemoryStream.Create;MemSteam.LoadFromFile(iFileName);MyCRC := TIdHashCRC32.Create;Result := MyCRC.HashStreamAsHex(MemSteam);MyCRC.Free;MemSteam.Free; end; { 獲取字符串CRC校驗碼 } function GetStringCRC(const Str: string): Cardinal; varMyCRC: TIdHashCRC32; beginMyCRC := TIdHashCRC32.Create;Result := MyCRC.HashValue(Str);MyCRC.Free; end; { 取文件MD5碼 } function GetFileMD5(const iFileName: string): String; varMemSteam: TMemoryStream;MyMD5 : TIdHashMessageDigest5; beginMemSteam := TMemoryStream.Create;MemSteam.LoadFromFile(iFileName);MyMD5 := TIdHashMessageDigest5.Create;Result := MyMD5.HashStreamAsHex(MemSteam);MyMD5.Free;MemSteam.Free; end; end.
轉載于:https://www.cnblogs.com/hnxxcxg/p/11079660.html
總結
以上是生活随笔為你收集整理的文件CRC和MD5校验的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 试管婴儿有没有年龄限制
- 下一篇: ServletRequest HttpS