Difference between revisions of "hash"

From Lazarus wiki
Jump to navigationJump to search
m (Fixed syntax highlighting)
 
(4 intermediate revisions by 4 users not shown)
Line 1: Line 1:
The package '''hash''' contains implementations for crc, md5, NTLM (1?) and, under Linux, crypt. Crypt might be better used from pkg "user".
+
{{hash}}
 +
 
 +
The package '''hash''' contains implementations for CRC, MD5, NTLM (1?) and, under Linux, crypt. Crypt might be better used from pkg "user".
  
 
== Unit md5 ==  
 
== Unit md5 ==  
Line 7: Line 9:
 
The test program md5test calculates the hash value for some reference string. The reference output is provided for comparison.
 
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:
+
A simple way to calculate the MD5 of a given string is to use MD5String followed by MD5Print, like this:
  
<syntaxhighlight>
+
<syntaxhighlight lang=pascal>
 
uses md5;
 
uses md5;
  
Line 18: Line 20:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Similarly to generate the md5 hash of a file one can use:
+
Similarly, to generate the MD5 hash of a file one can use:
  
<syntaxhighlight>
+
<syntaxhighlight lang=pascal>
 
uses md5;
 
uses md5;
  
Line 37: Line 39:
 
* Implements a MD4 digest algorithm (RFC 1320)-unit: md5.pp
 
* Implements a MD4 digest algorithm (RFC 1320)-unit: md5.pp
 
* Implements a MD5 digest algorithm (RFC 1321)-unit: md5.pp  
 
* Implements a MD5 digest algorithm (RFC 1321)-unit: md5.pp  
* Implements CRC algorithm-unit:crc.pas
+
* Implements CRC algorithm-unit: crc.pas
 +
* Implements SHA1 digst algorithm-unit: sha1.pp
 +
* Hash-based supporting HMAC-MD5 and HMAC-SHA-1 - unit: hmac.pp (FPC trunk)
  
Go to back [[Package_List|Packages List]]
+
== See also ==
 +
* [[HMAC-MD5]]
 +
* [[HMAC-SHA1]]
  
[[Category:Packages]]
+
Go back to [[Package_List|Packages List]]

Latest revision as of 12:23, 16 February 2020

English (en) français (fr) русский (ru)

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:

uses md5;

var
  Password, PasswordHash: string;
begin
  PasswordHash := MD5Print(MD5String(Password));

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

uses md5;

var
  PathToFile, FileHash: string;
begin
  FileHash := MD5Print(MD5File(PathToFile));

Hash units

The following hash units are available in FPC:

  • Implements a NTLM version 1.0, password hash algorithm-unit : ntlm.pas
  • Implements a MD2 digest algorithm (RFC 1319)-unit: md5.pp
  • Implements a MD4 digest algorithm (RFC 1320)-unit: md5.pp
  • Implements a MD5 digest algorithm (RFC 1321)-unit: md5.pp
  • Implements CRC algorithm-unit: crc.pas
  • Implements SHA1 digst algorithm-unit: sha1.pp
  • Hash-based supporting HMAC-MD5 and HMAC-SHA-1 - unit: hmac.pp (FPC trunk)

See also

Go back to Packages List