Menu

SHA1 Checksum

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