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;
|