![]() |
MD5File mit System.Hash?
Hallo!
What's New in Delphi and C++Builder XE8: Zitat:
Wenn nicht: Was ist die derzeit optimale (und schnellste) Methode, um mit Delphi einen MD5File Hash zu berechnen? |
AW: MD5File mit System.Hash?
Noch nie damit gearbeitet (bin noch auf XE7), aber ich dachte die "Update"-Methode wäre dafür?
Delphi-Quellcode:
procedure justHashThings();
const filePath = 'x:\teil 1.txt'; var hash: System.Hash.THashMD5; fileBytes: TBytes; begin fileBytes := TFile.ReadAllBytes(filePath); hash.Reset(); hash.Update(fileBytes); WriteLn('The hash is ', hash.HashAsString() ); end; |
AW: MD5File mit System.Hash?
VIELEN Dank für den Hinweis!
hab gleich eine schöne Funktion (für Copy&Paste) daraus gemacht:
Delphi-Quellcode:
Verbesserungsvorschläge?
function SystemHashFileMD5(const AFilePath: string; const AUpper: Boolean = True): string;
// VORHER prüfen, ob Datei existiert! var hash: System.Hash.THashMD5; fileBytes: TBytes; begin Result := ''; try fileBytes := TFile.ReadAllBytes(AFilePath); except Result := 'FileError'; EXIT; end; hash.Reset(); hash.Update(fileBytes); Result := hash.HashAsString; if AUpper then Result := UpperCase(Result); end; |
AW: MD5File mit System.Hash?
Spring4D bietet eine Möglichkeit Hashes (komfortabel) generieren zu lassen:
![]()
Delphi-Quellcode:
procedure Sample;
var LMD5Hasher: IMD5; LFileMD5Hash: String; begin LMD5Hasher:= CreateMD5; LFileMD5Hash := LMD5Hasher.ComputeHashOfFile('Dateipfad').ToString; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 19:00 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz