Add easy one first with fpc built-in

This commit is contained in:
R. Eric Wheeler 2017-02-27 07:43:55 -08:00
parent a93040eb70
commit 98a724fef3
6 changed files with 58 additions and 1 deletions

View File

@ -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.

21
MDTest.pp Normal file
View File

@ -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.