Add easy one first with fpc built-in
This commit is contained in:
parent
a93040eb70
commit
98a724fef3
38
Hash.Md.pp
38
Hash.Md.pp
|
@ -1,2 +1,38 @@
|
|||
{ md2, md4, md5 }
|
||||
{$codepage utf8}
|
||||
{$h+}
|
||||
{$mode objfpc}
|
||||
Unit Hash.Md;
|
||||
|
||||
interface
|
||||
|
||||
Uses
|
||||
md5,
|
||||
SysUtils,
|
||||
Classes;
|
||||
|
||||
Type
|
||||
Md = class(TObject)
|
||||
public
|
||||
function md2(S : UTF8String) : AnsiString;
|
||||
function md4(S : UTF8String) : AnsiString;
|
||||
function md5(S : UTF8STring) : AnsiString;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
function Md.md2(S : UTF8String) : AnsiString;
|
||||
begin
|
||||
Result := MD2Print(MDString(S, MD_VERSION_2));
|
||||
end;
|
||||
|
||||
function Md.md4(S : UTF8String) : AnsiString;
|
||||
begin
|
||||
Result := MD4Print(MDString(S, MD_VERSION_4));
|
||||
end;
|
||||
|
||||
function Md.md5(S : UTF8String) : AnsiString;
|
||||
begin
|
||||
Result := MD5Print(MDString(S, MD_VERSION_5));
|
||||
end;
|
||||
|
||||
End.
|
|
@ -0,0 +1,21 @@
|
|||
{$mode objfpc}
|
||||
{$codepage utf8}
|
||||
{$h+}
|
||||
Program MDTest;
|
||||
|
||||
Uses
|
||||
Hash.Md,
|
||||
SysUtils,
|
||||
DateUtils,
|
||||
Classes;
|
||||
|
||||
var
|
||||
Hash : Md;
|
||||
|
||||
begin
|
||||
Hash := Md.Create;
|
||||
Writeln('MD2 : ', Hash.md2(DateTimeToStr(Now)));
|
||||
Writeln('MD4 : ', Hash.md4(DateTimeToStr(Now)));
|
||||
Writeln('MD5 : ', Hash.md5(DateTimeToStr(Now)));
|
||||
Hash.Free;
|
||||
end.
|
Loading…
Reference in New Issue