c++builder xe8 hash calc
md5、sha256、sha384、sha512
file and string
sha256、sha384、sha512 must call load function .
system function not use any third party component.
- New in XE8! New System.Hash RTL unit, with hash functions to support the new HTTP framework
Caption:= System.Hash.THashMD5.GetHashString('ww');
id...
IdHashMessageDigest.pas
Idsslopensslheaders::Load(); //string
void __fastcall TFrmEncrypt::btnHashStringAsHexClick(TObject *Sender)
{ String instr = LabeledEdit1->Text;
TIdHashMessageDigest5 *md5 = new TIdHashMessageDigest5();
LabeledEdit2->Text = md5->HashStringAsHex(instr);
delete md5; TIdHashCRC32 *crc = new TIdHashCRC32();
LabeledEdit3->Text = crc->HashStringAsHex(instr);
delete crc; TIdHashSHA1 *sha1 = new TIdHashSHA1();
LabeledEdit4->Text = sha1->HashStringAsHex(instr);
delete sha1; TIdHashSHA224 *sha224 = new TIdHashSHA224();
LabeledEdit5->Text = sha224->HashStringAsHex(instr);
delete sha224; TIdHashSHA256 *sha256 = new TIdHashSHA256();
bool bf = sha256->IsAvailable();
LabeledEdit6->Text = sha256->HashStringAsHex(instr);
delete sha256; TIdHashSHA384 *sha384 = new TIdHashSHA384();
LabeledEdit7->Text = sha384->HashStringAsHex(instr);
delete sha384; TIdHashSHA512 *sha512 = new TIdHashSHA512();
LabeledEdit8->Text = sha512->HashStringAsHex(instr);
delete sha512;
} //stream
void __fastcall TFrmEncrypt::btnCalcClick(TObject *Sender)
{
String fileName(LabeledEdit1->Text);
TFileStream *fs;
fs = new TFileStream(fileName, fmOpenRead | fmShareDenyWrite); TIdHashMessageDigest5 *md5 = new TIdHashMessageDigest5();
LabeledEdit2->Text = md5->HashStreamAsHex(fs);
delete md5; const __int64 Istep = ;
fs->Seek(Istep, soBeginning);
TIdHashCRC32 *crc = new TIdHashCRC32();
LabeledEdit3->Text = crc->HashStreamAsHex(fs);
delete crc; fs->Seek(Istep, soBeginning);
TIdHashSHA1 *sha1 = new TIdHashSHA1();
LabeledEdit4->Text = sha1->HashStreamAsHex(fs);
delete sha1; fs->Seek(Istep, soBeginning);
TIdHashSHA224 *sha224 = new TIdHashSHA224();
LabeledEdit5->Text = sha224->HashStreamAsHex(fs);
delete sha224; fs->Seek(Istep, soBeginning);
TIdHashSHA256 *sha256 = new TIdHashSHA256();
LabeledEdit6->Text = sha256->HashStreamAsHex(fs);
delete sha256; fs->Seek(Istep, soBeginning);
TIdHashSHA384 *sha384 = new TIdHashSHA384();
LabeledEdit7->Text = sha384->HashStreamAsHex(fs);
delete sha384; fs->Seek(Istep, soBeginning);
TIdHashSHA512 *sha512 = new TIdHashSHA512();
LabeledEdit8->Text = sha512->HashStreamAsHex(fs);
delete sha512; delete fs;
} Idsslopensslheaders::Unload();