home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2002 December
/
Chip_2002-12_cd1.bin
/
ctenari
/
Hytha
/
MultiHSH.exe
/
SR.RAR
/
SR
/
Unit1.pas
< prev
Wrap
Pascal/Delphi Source File
|
2002-10-21
|
7KB
|
307 lines
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DCPcrypt2, DCPmd5, DCPmd4, DCPhaval, DCPtiger,
DCPsha512, DCPsha256, DCPsha1, DCPripemd160, DCPripemd128;
type
TForm1 = class(TForm)
DCP_md51: TDCP_md5;
Edit1: TEdit;
Button1: TButton;
Button2: TButton;
DCP_md41: TDCP_md4;
Memo1: TMemo;
DCP_haval1: TDCP_haval;
DCP_ripemd1281: TDCP_ripemd128;
DCP_ripemd1601: TDCP_ripemd160;
DCP_sha11: TDCP_sha1;
DCP_sha2561: TDCP_sha256;
DCP_sha3841: TDCP_sha384;
DCP_sha5121: TDCP_sha512;
DCP_tiger1: TDCP_tiger;
Memo2: TMemo;
Button3: TButton;
Label1: TLabel;
CheckBox1: TCheckBox;
Button4: TButton;
Button5: TButton;
SaveDialog1: TSaveDialog;
OpenDialog1: TOpenDialog;
Button6: TButton;
OpenDialog2: TOpenDialog;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
Form1.Close;
end;
procedure TForm1.Button2Click(Sender: TObject);
type HBuf=array[0..$FFFF] of Byte;
var S:String;
H:HBuf;
function HStr(B:HBuf;L:Word):String;
var Pom:String;
I:Word;
begin
Pom:='';
for I:=0 to ((L div 8)-1) do
Pom:=Pom+IntToHex(B[I],2);
HStr:=Pom;
end;
begin
Memo1.Lines.Clear;
with DCP_md41 do begin
Init;
S:=Edit1.Text;Update(S[1],Length(S));
Final(H);Memo1.Lines.Add(Algorithm+': "'+HStr(H,HashSize)+'"');
end;
with DCP_md51 do begin
Init;
S:=Edit1.Text;Update(S[1],Length(S));
Final(H);Memo1.Lines.Add(Algorithm+': "'+HStr(H,HashSize)+'"');
end;
with DCP_ripemd1281 do begin
Init;
S:=Edit1.Text;Update(S[1],Length(S));
Final(H);Memo1.Lines.Add(Algorithm+': "'+HStr(H,HashSize)+'"');
end;
with DCP_ripemd1601 do begin
Init;
S:=Edit1.Text;Update(S[1],Length(S));
Final(H);Memo1.Lines.Add(Algorithm+': "'+HStr(H,HashSize)+'"');
end;
with DCP_tiger1 do begin
Init;
S:=Edit1.Text;Update(S[1],Length(S));
Final(H);Memo1.Lines.Add(Algorithm+': "'+HStr(H,HashSize)+'"');
end;
with DCP_haval1 do begin
Init;
S:=Edit1.Text;Update(S[1],Length(S));
Final(H);Memo1.Lines.Add(Algorithm+': "'+HStr(H,HashSize)+'"');
end;
with DCP_sha11 do begin
Init;
S:=Edit1.Text;Update(S[1],Length(S));
Final(H);Memo1.Lines.Add(Algorithm+': "'+HStr(H,HashSize)+'"');
end;
with DCP_sha2561 do begin
Init;
S:=Edit1.Text;Update(S[1],Length(S));
Final(H);Memo1.Lines.Add(Algorithm+': "'+HStr(H,HashSize)+'"');
end;
with DCP_sha3841 do begin
Init;
S:=Edit1.Text;Update(S[1],Length(S));
Final(H);Memo1.Lines.Add(Algorithm+': "'+HStr(H,HashSize)+'"');
end;
with DCP_sha5121 do begin
Init;
S:=Edit1.Text;Update(S[1],Length(S));
Final(H);Memo1.Lines.Add(Algorithm+': "'+HStr(H,HashSize)+'"');
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
var I:Word;
Stejne:Boolean;
begin
Stejne:=True;
if Memo1.Lines.Count<>Memo2.Lines.Count then Stejne:=False else begin
for I:=0 to (Memo2.Lines.Count-1) do begin
if Memo1.Lines[I]<>Memo2.Lines[I] then
begin
Stejne:=False;
Break;
end;
end;
end;
if Stejne then begin
Label1.Caption:='OK: Hashes are the same';
Label1.Font.Color:=$00FF00;
end else begin
Label1.Caption:='ERR: Hashes are different';
Label1.Font.Color:=$0000FF;
end;
end;
procedure TForm1.CheckBox1Click(Sender: TObject);
begin
Memo1.ReadOnly:=not(CheckBox1.Checked);
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
if SaveDialog1.Execute then begin
Memo1.Lines.SaveToFile(SaveDialog1.FileName);
end;
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
if OpenDialog1.Execute then begin
Memo2.Lines.LoadFromFile(OpenDialog1.FileName);
end;
end;
procedure TForm1.Button6Click(Sender: TObject);
type HBuf=array[0..$FFFF] of Byte;
var S:String;
H,H2:HBuf;
F:File;
E:Integer;
function HStr(B:HBuf;L:Word):String;
var Pom:String;
I:Word;
begin
Pom:='';
for I:=0 to ((L div 8)-1) do
Pom:=Pom+IntToHex(B[I],2);
HStr:=Pom;
end;
begin
if OpenDialog2.Execute then begin
////////// init
Memo1.Lines.Clear;
SaveDialog1.FileName:=OpenDialog2.FileName+'.HSH';
AssignFile(F,OpenDialog2.FileName);
Reset(F,1);
with DCP_md41 do begin
Init;
end;
with DCP_md51 do begin
Init;
end;
with DCP_ripemd1281 do begin
Init;
end;
with DCP_ripemd1601 do begin
Init;
end;
with DCP_tiger1 do begin
Init;
end;
with DCP_haval1 do begin
Init;
end;
with DCP_sha11 do begin
Init;
end;
with DCP_sha2561 do begin
Init;
end;
with DCP_sha3841 do begin
Init;
end;
with DCP_sha5121 do begin
Init;
end;
////////// loop
while not eof(F) do begin
BlockRead(F,H2,$7FFF,E);
with DCP_md41 do begin
Update(H2,E);
end;
with DCP_md51 do begin
Update(H2,E);
end;
with DCP_ripemd1281 do begin
Update(H2,E);
end;
with DCP_ripemd1601 do begin
Update(H2,E);
end;
with DCP_tiger1 do begin
Update(H2,E);
end;
with DCP_haval1 do begin
Update(H2,E);
end;
with DCP_sha11 do begin
Update(H2,E);
end;
with DCP_sha2561 do begin
Update(H2,E);
end;
with DCP_sha3841 do begin
Update(H2,E);
end;
with DCP_sha5121 do begin
Update(H2,E);
end;
end;
////////// final
with DCP_md41 do begin
Final(H);Memo1.Lines.Add(Algorithm+': "'+HStr(H,HashSize)+'"');
end;
with DCP_md51 do begin
Final(H);Memo1.Lines.Add(Algorithm+': "'+HStr(H,HashSize)+'"');
end;
with DCP_ripemd1281 do begin
Final(H);Memo1.Lines.Add(Algorithm+': "'+HStr(H,HashSize)+'"');
end;
with DCP_ripemd1601 do begin
Final(H);Memo1.Lines.Add(Algorithm+': "'+HStr(H,HashSize)+'"');
end;
with DCP_tiger1 do begin
Final(H);Memo1.Lines.Add(Algorithm+': "'+HStr(H,HashSize)+'"');
end;
with DCP_haval1 do begin
Final(H);Memo1.Lines.Add(Algorithm+': "'+HStr(H,HashSize)+'"');
end;
with DCP_sha11 do begin
Final(H);Memo1.Lines.Add(Algorithm+': "'+HStr(H,HashSize)+'"');
end;
with DCP_sha2561 do begin
Final(H);Memo1.Lines.Add(Algorithm+': "'+HStr(H,HashSize)+'"');
end;
with DCP_sha3841 do begin
Final(H);Memo1.Lines.Add(Algorithm+': "'+HStr(H,HashSize)+'"');
end;
with DCP_sha5121 do begin
Final(H);Memo1.Lines.Add(Algorithm+': "'+HStr(H,HashSize)+'"');
end;
CloseFile(F);
////////// Konec hashovani
end;
end;
end.