diff options
| author | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2008-11-09 16:06:45 +0100 |
|---|---|---|
| committer | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2008-11-09 16:06:45 +0100 |
| commit | a2bfc5e9f4c66db6a29810c064b981d772aefb2a (patch) | |
| tree | 7ea6efd4ffe7e265a9dee447693e36332e36f375 /UChecksumDruid.pas | |
| parent | 8712e487d22e7650a3dc529a63a70cf1d64e1bc4 (diff) | |
| download | tuxcmd-a2bfc5e9f4c66db6a29810c064b981d772aefb2a.tar.xz | |
Port CRC32 and MD5 functions to standard FreePascal RTL
Added compat dir for Kylix compatibility
Diffstat (limited to 'UChecksumDruid.pas')
| -rw-r--r-- | UChecksumDruid.pas | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/UChecksumDruid.pas b/UChecksumDruid.pas index 18e4243..bbe0b73 100644 --- a/UChecksumDruid.pas +++ b/UChecksumDruid.pas @@ -76,7 +76,7 @@ var implementation -uses ULocale, UCoreUtils, ULibc, UCore, DateUtils, UConfig, StrUtils; +uses ULocale, UCoreUtils, ULibc, UCore, DateUtils, UConfig, StrUtils, md5, crc; procedure TFChecksumDruid.FormCreate(Sender: TObject); @@ -483,7 +483,8 @@ var FD: TEngineFileDes; Error, Count: integer; Buffer: Pointer; CRC: LongWord; - MD5Hash: THash_MD5; + MDContext: TMDContext; + MDDigest: TMDDigest; begin HashString := ''; Result := False; @@ -494,9 +495,8 @@ begin ErrorLabel.Caption := ErrorLabel.Caption + LANGAnErrorOccuredWhileInitializingMemoryBlock + #10; Exit; end; - CRC := $FFFFFFFF; - MD5Hash := nil; - if not IsItSFV then MD5Hash := THash_MD5.Create; + CRC := 0; + if not IsItSFV then MDInit(MDContext, MD_VERSION_5); FD := Engine.OpenFile(FName, omRead, Error); if Error <> 0 then begin @@ -511,7 +511,7 @@ begin Exit; end; if IsItSFV then CRC := CRC32(CRC, Buffer, Count) - else MD5Hash.Calc(Buffer^, Count); + else MDUpdate(MDContext, Buffer^, Count); Progress.Value := Progress.Value + Count; Progress.Text := Format('%d %%', [Trunc(Progress.Fraction * 100)]); Application.ProcessMessages; @@ -520,11 +520,10 @@ begin Engine.CloseFile(FD); libc_free(Buffer); - if IsItSFV then HashString := IntToHex(not CRC, 8) else + if IsItSFV then HashString := IntToHex(CRC, 8) else begin - MD5Hash.Done; - HashString := MD5Hash.GetKeyStrH; - MD5Hash.Free; + MDFinal(MDContext, MDDigest); + HashString := MDPrint(MDDigest); end; Result := True; end; |
