hash: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: hash
| Old | New | Line | |
|---|---|---|---|
| 1 | + | The package **hash** contains implementations for CRC, MD5, NTLM (1?) and, under Linux, crypt. Crypt might be better used from pkg "user". | |
| 2 | + | ||
| 3 | + | ## Unit md5 | |
| 4 | + | ||
| 5 | + | 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. | |
| 6 | + | ||
| 7 | + | The test program md5test calculates the hash value for some reference string. The reference output is provided for comparison. | |
| 8 | + | ||
| 9 | + | A simple way to calculate the MD5 of a given string is to use MD5String followed by MD5Print, like this: | |
| 10 | + | ||
| 11 | + | ``` pascal | |
| 12 | + | uses md5; | |
| 13 | + | ||
| 14 | + | var | |
| 15 | + | Password, PasswordHash: string; | |
| 16 | + | begin | |
| 17 | + | PasswordHash := MD5Print(MD5String(Password)); | |
| 18 | + | ``` | |
| 19 | + | ||
| 20 | + | Similarly, to generate the MD5 hash of a file one can use: | |
| 21 | + | ||
| 22 | + | ``` pascal | |
| 23 | + | uses md5; | |
| 24 | + | ||
| 25 | + | var | |
| 26 | + | PathToFile, FileHash: string; | |
| 27 | + | begin | |
| 28 | + | FileHash := MD5Print(MD5File(PathToFile)); | |
| 29 | + | ``` | |
| 30 | + | ||
| 31 | + | ## Hash units | |
| 32 | + | ||
| 33 | + | The following hash units are available in FPC: | |
| 34 | + | ||
| 35 | + | - Implements a NTLM version 1.0, password hash algorithm-unit : ntlm.pas | |
| 36 | + | - Implements a MD2 digest algorithm (RFC 1319)-unit: md5.pp | |
| 37 | + | - Implements a MD4 digest algorithm (RFC 1320)-unit: md5.pp | |
| 38 | + | - Implements a MD5 digest algorithm (RFC 1321)-unit: md5.pp | |
| 39 | + | - Implements CRC algorithm-unit: crc.pas | |
| 40 | + | - Implements SHA1 digst algorithm-unit: sha1.pp | |
| 41 | + | - Hash-based supporting HMAC-MD5 and HMAC-SHA-1 - unit: hmac.pp (FPC trunk) | |
| 42 | + | ||
| 43 | + | ## See also | |
| 44 | + | ||
| 45 | + | - [[HMAC-MD5]] | |
| 46 | + | - [[HMAC-SHA1]] | |
| 47 | + | ||
| 48 | + | Go back to [[Package List|Packages List]] | |
| 49 | + | ||
| 50 | + | --- | |
| 51 | + | *From the Free Pascal wiki, page "hash", as it stood on 2020-02-16 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* |
