Menu

MD5 Checksum

2024-07-27 - Kryptografia
//---------------------------------------------------------------------------
#include 
//---------------------------------------------------------------------------
UnicodeString __fastcall TForm1::GetMD5ChecksumFromFile(const UnicodeString PathFile){
 
    UnicodeString ret;
    TFileStream *FileStream = NULL;
    TIdHashMessageDigest5 *MD5 = NULL;
    try {
        FileStream = new TFileStream(PathFile, fmOpenRead | fmShareDenyWrite);
        MD5 = new TIdHashMessageDigest5();
        ret = MD5->HashStreamAsHex(FileStream);
 
        MD5->Free();
        FileStream->Free();
    } catch (...) {
        MD5->Free();
        FileStream->Free();
    }
    return ret;
}
//---------------------------------------------------------------------------