System.Hash.THashMD5

From Appmethod Libraries
Jump to: navigation, search

Object Pascal

  THashMD5 = record
  private type
    TContextState = array [0..15] of Cardinal;
    TContextBuffer = array [0..63] of Byte;
  private
    FPadding: TContextBuffer;
    FContextState: array [0..3] of Cardinal;
    FContextCount: array [0..1] of Cardinal;
    FContextBuffer: TContextBuffer;
    FFinalized: Boolean;
    procedure Transform(const ABlock: PByte; AShift: Integer);
    procedure Decode(const Dst: PCardinal; const Src: PByte; Len: Integer; AShift: Integer);
    procedure Encode(const Dst: PByte; const Src: PCardinal; Len: Integer);
    procedure FinalizeHash;
    procedure Update(const AData: PByte; ALength: Cardinal); overload;
    function GetDigest: TBytes;
  public
    class function Create: THashMD5; static; inline;
    procedure Reset;
    procedure Update(const AData; ALength: Cardinal); overload;
    procedure Update(const AData: TBytes; ALength: Cardinal = 0); overload; inline;
    procedure Update(const Input: string); overload; inline;
    function GetBlockSize: Integer; inline;
    function GetHashSize: Integer; inline;
    function HashAsBytes: TBytes; inline;
    function HashAsString: string; inline;
    class function GetHashBytes(const AData: string): TBytes; static;
    class function GetHashString(const AString: string): string; static;
    class function GetHMAC(const AData, AKey: string): string; static; inline;
    class function GetHMACAsBytes(const AData, AKey: string): TBytes; overload;  static;
    class function GetHMACAsBytes(const AData: string; const AKey: TBytes): TBytes; overload; static;
    class function GetHMACAsBytes(const AData: TBytes; const AKey: string): TBytes; overload; static;
    class function GetHMACAsBytes(const AData, AKey: TBytes): TBytes; overload; static;
  end;

C++

struct DECLSPEC_DRECORD THashMD5
{
private:
    typedef System::StaticArray<unsigned, 16> TContextState;
    typedef System::StaticArray<System::Byte, 64> TContextBuffer;
private:
    TContextBuffer FPadding;
    System::StaticArray<unsigned, 4> FContextState;
    System::StaticArray<unsigned, 2> FContextCount;
    TContextBuffer FContextBuffer;
    bool FFinalized;
    void __fastcall Transform(const System::PByte ABlock, int AShift);
    void __fastcall Decode(const System::PCardinal Dst, const System::PByte Src, int Len, int AShift);
    void __fastcall Encode(const System::PByte Dst, const System::PCardinal Src, int Len);
    void __fastcall FinalizeHash(void);
    void __fastcall Update(const System::PByte AData, unsigned ALength)/* overload */;
#ifndef _WIN64
    System::DynamicArray<System::Byte> __fastcall GetDigest(void);
#else /* _WIN64 */
    System::TArray__1<System::Byte> __fastcall GetDigest(void);
#endif /* _WIN64 */
public:
    static THashMD5 __fastcall Create();
    void __fastcall Reset(void);
    void __fastcall Update(const void *AData, unsigned ALength)/* overload */;
#ifndef _WIN64
    void __fastcall Update(const System::DynamicArray<System::Byte> AData, unsigned ALength = (unsigned)(0x0))/* overload */;
#else /* _WIN64 */
    void __fastcall Update(const System::TArray__1<System::Byte> AData, unsigned ALength = (unsigned)(0x0))/* overload */;
#endif /* _WIN64 */
    void __fastcall Update(const System::UnicodeString Input)/* overload */;
    int __fastcall GetBlockSize(void);
    int __fastcall GetHashSize(void);
#ifndef _WIN64
    System::DynamicArray<System::Byte> __fastcall HashAsBytes(void);
#else /* _WIN64 */
    System::TArray__1<System::Byte> __fastcall HashAsBytes(void);
#endif /* _WIN64 */
    System::UnicodeString __fastcall HashAsString(void);
#ifndef _WIN64
    static System::DynamicArray<System::Byte> __fastcall GetHashBytes(const System::UnicodeString AData);
#else /* _WIN64 */
    static System::TArray__1<System::Byte> __fastcall GetHashBytes(const System::UnicodeString AData);
#endif /* _WIN64 */
    static System::UnicodeString __fastcall GetHashString(const System::UnicodeString AString);
    static System::UnicodeString __fastcall GetHMAC(const System::UnicodeString AData, const System::UnicodeString AKey);
#ifndef _WIN64
    static System::DynamicArray<System::Byte> __fastcall GetHMACAsBytes(const System::UnicodeString AData, const System::UnicodeString AKey)/* overload */;
    static System::DynamicArray<System::Byte> __fastcall GetHMACAsBytes(const System::UnicodeString AData, const System::DynamicArray<System::Byte> AKey)/* overload */;
    static System::DynamicArray<System::Byte> __fastcall GetHMACAsBytes(const System::DynamicArray<System::Byte> AData, const System::UnicodeString AKey)/* overload */;
    static System::DynamicArray<System::Byte> __fastcall GetHMACAsBytes(const System::DynamicArray<System::Byte> AData, const System::DynamicArray<System::Byte> AKey)/* overload */;
#else /* _WIN64 */
    static System::TArray__1<System::Byte> __fastcall GetHMACAsBytes(const System::UnicodeString AData, const System::UnicodeString AKey)/* overload */;
    static System::TArray__1<System::Byte> __fastcall GetHMACAsBytes(const System::UnicodeString AData, const System::TArray__1<System::Byte> AKey)/* overload */;
    static System::TArray__1<System::Byte> __fastcall GetHMACAsBytes(const System::TArray__1<System::Byte> AData, const System::UnicodeString AKey)/* overload */;
    static System::TArray__1<System::Byte> __fastcall GetHMACAsBytes(const System::TArray__1<System::Byte> AData, const System::TArray__1<System::Byte> AKey)/* overload */;
#endif /* _WIN64 */
};

Properties

Type Visibility Source Unit Parent
record
struct
public
System.Hash.pas
System.Hash.hpp
System.Hash System.Hash

Description

A record that implements the MD5 hash type.

THashMD5 provides methods such as:

  • Update: Updates the hash value with the provided data.
  • GetHashString: Returns hash value of the provided String.
  • GetHMAC: Returns a String representation associated with the HMAC authentication (Hash-based message authentication code).

See Also