Hash

This is an old revision of Hash, edited by Sekelsenmat at . The current revision is 58099.

The package hash contains implementations for crc, md5, NTLM (1?) and, under Linux, crypt. Crypt might be better used from pkg "user".

Unit md5

This unit implements the MD5 digest algorithm according to the specifications in RFC 1321. There are routines to calculate hashes from some buffer, or a hash from an entire file.

The test program md5test calculates the hash value for some reference string. The reference output is provided for comparison.

A simple way to calculate the md5 of a given string is to use MD5String followed by MD5Print, like this:

<delphi> uses md5;

var

 Password, PasswordHash: string;

begin

 PasswordHash := MD5Print(MD5String(Password));

</delphi>

Similarly to generate the md5 hash of a file one can use:

<delphi> uses md5;

var

 PathToFile, FileHash: string;

begin

 FileHash := MD5Print(MD5File(PathToFile));

</delphi>

Hash units

The following hash units are available in FPC:

Go to back Packages List