Da gibt es z.B. sowas
http://www.delphipraxis.net/122045-b...tml#post848903
welches man sich so kapseln könnte.
Delphi-Quellcode:
Type
ThMD5 = Record
Data: MD5_CTX;
Procedure Init;
Procedure Update(Input: Pointer; inLen: LongWord);
Function Final: MD5_RES;
End;
Dieser Record ist nun vollkommen kompatibel zur
WinAPI
oder man nutzt die eingebetetten Record-Methoden.
Und am Ende kann man es auch noch ausmotzen, bis zum Geht nicht mehr und es bleibt immernoch kompatibel zur
WinAPI.
Außerdem läßt sich soein Record direkt und ohne umwege irgendwo abspeichern/übertragen (Stream, Datei,
Indy usw.)
Delphi-Quellcode:
Type
ThMD5 = packed Record
Data: MD5_CTX;
Class Operator Implicit(Value: MD5_CTX): ThMD5; Inline;
Class Operator Implicit(Rec: ThMD5): MD5_CTX; Inline;
Class Operator Implicit(Rec: ThMD5): MD5_DIGEST; Inline;
Class Operator Equal (Left, Right: MD5_CTX): Boolean; Inline;
Class Operator Equal (Left, Right: MD5_DIGEST): Boolean; Inline;
Class Operator NotEqual(Left, Right: MD5_CTX): Boolean; Inline;
Class Operator NotEqual(Left, Right: MD5_DIGEST): Boolean; Inline;
Procedure Init; Inline;
Procedure Update(Input: Pointer; inLen: LongWord); Overload; Inline;
Procedure Update(Const Input: AnsiString); Overload; Inline;
Procedure Update(Const Input: WideString); Overload; Inline;
Procedure Update(Input: TStream; inLen: LongInt); Overload;
Function Final: MD5_RES; Inline;
Function Calc(Input: Pointer; inLen: LongWord): ThMD5; Overload; Inline;
Function Calc(Const Input: AnsiString): ThMD5; Overload; Inline;
Function Calc(Const Input: WideString): ThMD5; Overload; Inline;
Function Calc(Var Input: TnStream; inLen: LongInt): ThMD5; Overload; Inline;
Function CalcFile(Const FileName: WideString; Var Hash: MD5_DIGEST): Boolean;
Function asBin: MD5_DIGEST; Inline;
Function asHexString: String;
Function asGUID: TGUID;
End;