Exetools

Exetools (https://forum.exetools.com/index.php)
-   Source Code (https://forum.exetools.com/forumdisplay.php?f=46)
-   -   Delphi Encryption Compendium HAVAL Modification (https://forum.exetools.com/showthread.php?t=17017)

chessgod101 08-29-2015 10:10

Delphi Encryption Compendium HAVAL Modification
 
I have been working with the Delphi Encryption Compendium lately and made a small change to the HAVAL hash function to allow you to specify rounds. The author originally had fixed round types for each length.


Download:

Code:

http://rghost.net/8qktp6spV
Here is a code example of how to specify haval rounds and hash a string.
Code:

Uses DECHash, DECFmt;

Function GetHAVAL_Ansi(input: ansistring):String;
var
val:tstringstream;
hash: tHash_haval128;
len:int64;
Begin
val:=tstringstream.Create;
len:=length(input);
val.Write(input[1],Len);
val.Seek(0, soFromBeginning);
DECHash.sHavalRounds:=4;
hash:=thash_haval128.Create();
result:=string(hash.CalcStream(val,Len,TFormat_HEX)); //output is rawbytestring. We must cast it to string type.
hash.Free;
val.Free;
End;

Function GetHAVAL_unicode(input: unicodestring):String;
var
val:tstringstream;
hash: tHash_haval128;
len:int64;
Begin
val:=tstringstream.Create;
len:=length(input)*2;
val.Write(input[1],Len);
val.Seek(0, soFromBeginning);
DECHash.sHavalRounds:=4; //Specify the rounds here...
hash:=thash_haval128.Create();
result:=string(hash.CalcStream(val,Len,TFormat_HEX)); //output is rawbytestring. We must cast it to string type.
hash.Free;
val.Free;
End;



All times are GMT +8. The time now is 16:07.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX