Digest()

From TinyMUX
Revision as of 18:22, 16 January 2010 by Brazil (talk | contribs) (→‎Server Differences)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Description

FUNCTION: digest(algorithm[,string])

Returns a checksum (hash, digest, fingerprint, etc.) of string using the given algorithm. While the exact list of algorithms varies when SSL support is enabled, the following is a representative sample:

md2 md4 md5 sha sha1 sha224 sha256 sha384 sha512 dss1 mdc2 ripemd160

Digest exposes SHA-0 (an earlier version of SHA-1) as the sha algorithm.

Related Topics: crc32(), sha0(), sha1().

Examples

> think digest(sha1,abc)
A9993E364706816ABA3E25717850C26C9CD0D89D
> think digest(sha1,abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq)
84983E441C3BD26EBAAE4AA1F95129E5E54670F1

Quirks

Note that digest() is currently the only function in TinyMUX which considers the comma after the first parameter (algorithm) to be significant while treating any remaining commas as part of the 2nd (string) parameter. This may be confusing, but it is compatible with PennMUSH behavior. For example,

digest(sha1,abc,def)

produces a SHA-1 digest of "abc,def" not "abcdef".

Server Differences

TinyMUX hashes contain upper-case letters while PennMUSH produces lower-case letters.

Digest is not available in TinyMUX 2.7 or earlier. It was added to 2.9 in January 2010.

Without SSL, on PennMUSH and TinyMUX, only the sha and sha1 algorithms, respectively, are enabled.