View Single Post
  #1  
Old 08-29-2015, 10:10
chessgod101's Avatar
chessgod101 chessgod101 is offline
Co-Administrator
 
Join Date: Jan 2011
Location: United States
Posts: 535
Rept. Given: 2,221
Rept. Rcvd 691 Times in 219 Posts
Thanks Given: 703
Thanks Rcvd at 939 Times in 186 Posts
chessgod101 Reputation: 500-699 chessgod101 Reputation: 500-699 chessgod101 Reputation: 500-699 chessgod101 Reputation: 500-699 chessgod101 Reputation: 500-699 chessgod101 Reputation: 500-699
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;
__________________
"As the island of our knowledge grows, so does the shore of our ignorance." John Wheeler
Reply With Quote
The Following 2 Users Gave Reputation+1 to chessgod101 For This Useful Post:
Kjacky (08-29-2015), Storm Shadow (08-31-2015)
The Following 5 Users Say Thank You to chessgod101 For This Useful Post:
anon_c (09-01-2015), Jay (08-29-2015), Kjacky (08-29-2015), niculaita (08-29-2015), yoza (08-30-2015)