mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 04:26:13 +02:00
* added inlined wrappers to the new MD functions to keep compatiblity with 2.0.4
git-svn-id: trunk@6405 -
This commit is contained in:
parent
258708e6d3
commit
757e36030f
@ -18,6 +18,7 @@
|
|||||||
unit md5;
|
unit md5;
|
||||||
|
|
||||||
{$mode objfpc}
|
{$mode objfpc}
|
||||||
|
{$inline on}
|
||||||
{$h+}
|
{$h+}
|
||||||
|
|
||||||
interface
|
interface
|
||||||
@ -54,7 +55,7 @@ type
|
|||||||
|
|
||||||
|
|
||||||
(******************************************************************************
|
(******************************************************************************
|
||||||
* Raw functions
|
* Core raw functions
|
||||||
******************************************************************************)
|
******************************************************************************)
|
||||||
|
|
||||||
procedure MDInit(var Context: TMDContext; const Version: TMDVersion);
|
procedure MDInit(var Context: TMDContext; const Version: TMDVersion);
|
||||||
@ -63,6 +64,24 @@ procedure MDFinal(var Context: TMDContext; var Digest: TMDDigest);
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(******************************************************************************
|
||||||
|
* Dedicated raw functions
|
||||||
|
******************************************************************************)
|
||||||
|
|
||||||
|
procedure MD2Init(var Context: TMDContext); inline;
|
||||||
|
procedure MD2Update(var Context: TMDContext; var Buf; const BufLen: PtrUInt); inline;
|
||||||
|
procedure MD2Final(var Context: TMDContext; var Digest: TMDDigest); inline;
|
||||||
|
|
||||||
|
procedure MD4Init(var Context: TMDContext); inline;
|
||||||
|
procedure MD4Update(var Context: TMDContext; var Buf; const BufLen: PtrUInt); inline;
|
||||||
|
procedure MD4Final(var Context: TMDContext; var Digest: TMDDigest); inline;
|
||||||
|
|
||||||
|
procedure MD5Init(var Context: TMDContext); inline;
|
||||||
|
procedure MD5Update(var Context: TMDContext; var Buf; const BufLen: PtrUInt); inline;
|
||||||
|
procedure MD5Final(var Context: TMDContext; var Digest: TMDDigest); inline;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(******************************************************************************
|
(******************************************************************************
|
||||||
* Auxilary functions
|
* Auxilary functions
|
||||||
******************************************************************************)
|
******************************************************************************)
|
||||||
@ -70,9 +89,38 @@ procedure MDFinal(var Context: TMDContext; var Digest: TMDDigest);
|
|||||||
function MDString(const S: String; const Version: TMDVersion): TMDDigest;
|
function MDString(const S: String; const Version: TMDVersion): TMDDigest;
|
||||||
function MDBuffer(var Buf; const BufLen: PtrUInt; const Version: TMDVersion): TMDDigest;
|
function MDBuffer(var Buf; const BufLen: PtrUInt; const Version: TMDVersion): TMDDigest;
|
||||||
function MDFile(const Filename: String; const Version: TMDVersion; const Bufsize: PtrUInt = MDDefBufSize): TMDDigest;
|
function MDFile(const Filename: String; const Version: TMDVersion; const Bufsize: PtrUInt = MDDefBufSize): TMDDigest;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(******************************************************************************
|
||||||
|
* Dedicated auxilary functions
|
||||||
|
******************************************************************************)
|
||||||
|
|
||||||
|
function MD2String(const S: String): TMDDigest; inline;
|
||||||
|
function MD2Buffer(var Buf; const BufLen: PtrUInt): TMDDigest; inline;
|
||||||
|
function MD2File(const Filename: String; const Bufsize: PtrUInt = MDDefBufSize): TMDDigest; inline;
|
||||||
|
|
||||||
|
function MD4String(const S: String): TMDDigest; inline;
|
||||||
|
function MD4Buffer(var Buf; const BufLen: PtrUInt): TMDDigest; inline;
|
||||||
|
function MD4File(const Filename: String; const Bufsize: PtrUInt = MDDefBufSize): TMDDigest; inline;
|
||||||
|
|
||||||
|
function MD5String(const S: String): TMDDigest; inline;
|
||||||
|
function MD5Buffer(var Buf; const BufLen: PtrUInt): TMDDigest; inline;
|
||||||
|
function MD5File(const Filename: String; const Bufsize: PtrUInt = MDDefBufSize): TMDDigest; inline;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(******************************************************************************
|
||||||
|
* Helper functions
|
||||||
|
******************************************************************************)
|
||||||
|
|
||||||
function MDPrint(const Digest: TMDDigest): String;
|
function MDPrint(const Digest: TMDDigest): String;
|
||||||
function MDMatch(const Digest1, Digest2: TMDDigest): Boolean;
|
function MDMatch(const Digest1, Digest2: TMDDigest): Boolean;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
|
||||||
@ -123,8 +171,8 @@ const
|
|||||||
31, 26, 219, 153, 141, 51, 159, 17, 131, 20
|
31, 26, 219, 153, 141, 51, 159, 17, 131, 20
|
||||||
);
|
);
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Cardinal;
|
||||||
j: Integer;
|
j: Cardinal;
|
||||||
t: Cardinal;
|
t: Cardinal;
|
||||||
x: array[0..47] of Byte;
|
x: array[0..47] of Byte;
|
||||||
begin
|
begin
|
||||||
@ -418,6 +466,50 @@ begin
|
|||||||
FillChar(Context, SizeOf(TMDContext), 0);
|
FillChar(Context, SizeOf(TMDContext), 0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure MD2Init(var Context: TMDContext);
|
||||||
|
begin
|
||||||
|
MDInit(Context, MD_VERSION_2);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure MD2Update(var Context: TMDContext; var Buf; const BufLen: PtrUInt);
|
||||||
|
begin
|
||||||
|
MDUpdate(Context, Buf, BufLen);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure MD2Final(var Context: TMDContext; var Digest: TMDDigest);
|
||||||
|
begin
|
||||||
|
MDFinal(Context, Digest);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure MD4Init(var Context: TMDContext);
|
||||||
|
begin
|
||||||
|
MDInit(Context, MD_VERSION_4);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure MD4Update(var Context: TMDContext; var Buf; const BufLen: PtrUInt);
|
||||||
|
begin
|
||||||
|
MDUpdate(Context, Buf, BufLen);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure MD4Final(var Context: TMDContext; var Digest: TMDDigest);
|
||||||
|
begin
|
||||||
|
MDFinal(Context, Digest);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure MD5Init(var Context: TMDContext);
|
||||||
|
begin
|
||||||
|
MDInit(Context, MD_VERSION_5);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure MD5Update(var Context: TMDContext; var Buf; const BufLen: PtrUInt);
|
||||||
|
begin
|
||||||
|
MDUpdate(Context, Buf, BufLen);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure MD5Final(var Context: TMDContext; var Digest: TMDDigest);
|
||||||
|
begin
|
||||||
|
MDFinal(Context, Digest);
|
||||||
|
end;
|
||||||
|
|
||||||
function MDString(const S: String; const Version: TMDVersion): TMDDigest;
|
function MDString(const S: String; const Version: TMDVersion): TMDDigest;
|
||||||
var
|
var
|
||||||
@ -472,6 +564,50 @@ begin
|
|||||||
FileMode := ofm;
|
FileMode := ofm;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function MD2String(const S: String): TMDDigest;
|
||||||
|
begin
|
||||||
|
Result := MDString(S, MD_VERSION_2);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function MD2Buffer(var Buf; const BufLen: PtrUInt): TMDDigest;
|
||||||
|
begin
|
||||||
|
Result := MDBuffer(Buf, BufLen, MD_VERSION_2);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function MD2File(const Filename: String; const Bufsize: PtrUInt): TMDDigest;
|
||||||
|
begin
|
||||||
|
Result := MDFile(Filename, MD_VERSION_2, Bufsize);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function MD4String(const S: String): TMDDigest;
|
||||||
|
begin
|
||||||
|
Result := MDString(S, MD_VERSION_4);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function MD4Buffer(var Buf; const BufLen: PtrUInt): TMDDigest;
|
||||||
|
begin
|
||||||
|
Result := MDBuffer(Buf, BufLen, MD_VERSION_4);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function MD4File(const Filename: String; const Bufsize: PtrUInt): TMDDigest;
|
||||||
|
begin
|
||||||
|
Result := MDFile(Filename, MD_VERSION_4, Bufsize);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function MD5String(const S: String): TMDDigest;
|
||||||
|
begin
|
||||||
|
Result := MDString(S, MD_VERSION_5);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function MD5Buffer(var Buf; const BufLen: PtrUInt): TMDDigest;
|
||||||
|
begin
|
||||||
|
Result := MDBuffer(Buf, BufLen, MD_VERSION_5);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function MD5File(const Filename: String; const Bufsize: PtrUInt): TMDDigest;
|
||||||
|
begin
|
||||||
|
Result := MDFile(Filename, MD_VERSION_5, Bufsize);
|
||||||
|
end;
|
||||||
|
|
||||||
function MDPrint(const Digest: TMDDigest): String;
|
function MDPrint(const Digest: TMDDigest): String;
|
||||||
var
|
var
|
||||||
@ -483,7 +619,6 @@ begin
|
|||||||
Result := LowerCase(Result);
|
Result := LowerCase(Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function MDMatch(const Digest1, Digest2: TMDDigest): Boolean;
|
function MDMatch(const Digest1, Digest2: TMDDigest): Boolean;
|
||||||
var
|
var
|
||||||
A: array[0..3] of Cardinal absolute Digest1;
|
A: array[0..3] of Cardinal absolute Digest1;
|
||||||
|
Loading…
Reference in New Issue
Block a user