From 4797195ad310e8f6dc2eae8eb86fe14683f77cf0 Mon Sep 17 00:00:00 2001 From: Razor12911 Date: Sun, 22 May 2022 23:23:15 +0200 Subject: [PATCH] added CRC32 function --- common/Utils.pas | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/common/Utils.pas b/common/Utils.pas index 12be1f0..f48dabd 100644 --- a/common/Utils.pas +++ b/common/Utils.pas @@ -7,7 +7,7 @@ uses WinAPI.Windows, WinAPI.PsAPI, System.SysUtils, System.Classes, System.SyncObjs, System.Math, System.Types, System.AnsiStrings, System.StrUtils, System.IniFiles, System.IOUtils, - System.RTLConsts, System.TypInfo, System.Net.HttpClientComponent, + System.RTLConsts, System.TypInfo, System.ZLib, System.Net.HttpClientComponent, System.Generics.Defaults, System.Generics.Collections; procedure ShowMessage(Msg: string; Caption: string = ''); @@ -355,6 +355,7 @@ type PExecOutput = ^TExecOutput; TExecOutput = reference to procedure(const Buffer: Pointer; Size: Integer); +function CRC32(CRC: longword; buf: PByte; len: cardinal): longword; function Hash32(CRC: longword; buf: PByte; len: cardinal): longword; procedure XORBuffer(InBuff: PByte; InSize: Integer; KeyBuff: PByte; @@ -2082,6 +2083,11 @@ begin AddByte((PByte(AData) + I)^); end; +function CRC32(CRC: longword; buf: PByte; len: cardinal): longword; +begin + Result := System.ZLib.CRC32(CRC, buf, len); +end; + function Hash32(CRC: longword; buf: PByte; len: cardinal): longword; begin Result := crc32c(CRC, PAnsiChar(buf), len);