MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 1 | SYNOPSIS |
Zesstra | d59c389 | 2019-11-28 20:53:39 +0100 | [diff] [blame] | 2 | #include <tls.h> |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 3 | |
| 4 | string hash(int method, string arg [, int iterations ] ) |
Zesstra | d59c389 | 2019-11-28 20:53:39 +0100 | [diff] [blame] | 5 | string hash(int method, bytes arg [, int iterations ] ) |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 6 | string hash(int method, int * arg [, int iterations ] ) |
| 7 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 8 | DESCRIPTION |
| 9 | Calculate the hash from <arg> as determined by <method>. The hash is |
| 10 | calculated with <iterations> iterations, default is 1 iteration. |
| 11 | If <arg> is a string, it will be converted to a UTF-8 byte sequence |
| 12 | of which then the hash will be created. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 13 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 14 | <method> is one of the TLS_HASH_ constants defined in tls.h; not |
| 15 | all recognized methods may be supported for a given driven: |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 16 | |
| 17 | TLS_HASH_SHA1 (1) |
| 18 | TLS_HASH_SHA224 (2) |
| 19 | TLS_HASH_SHA256 (3) |
| 20 | TLS_HASH_SHA384 (4) |
| 21 | TLS_HASH_SHA512 (5) |
| 22 | TLS_HASH_MD5 (6) |
| 23 | TLS_HASH_RIPEMD160 (7) |
| 24 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 25 | If the driver is compiled without OpenSSL or GCrypt support |
| 26 | only TLS_HASH_SHA1 and TLS_HASH_MD5 are available. |
Zesstra | d59c389 | 2019-11-28 20:53:39 +0100 | [diff] [blame] | 27 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 28 | The efun costs 10 ticks per iteration. |
Zesstra | d59c389 | 2019-11-28 20:53:39 +0100 | [diff] [blame] | 29 | |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 30 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 31 | EXAMPLES |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 32 | string s; |
| 33 | |
| 34 | s = hash(TLS_HASH_SHA1, "Hello", 2); |
| 35 | s = hash(TLS_HASH_SHA1, ({ 'H', 'e', 'l', 'l', 'o' }) ) |
| 36 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 37 | HISTORY |
| 38 | Introduced in LDMud 3.3.714. |
| 39 | LDMud 3.3.719 added the iteration-based evaluation cost. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 40 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 41 | SEE ALSO |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 42 | crypt(E), md5(E), md5_crypt(E), sha1(E), hmac(E) |