Function: secure-hash

secure-hash is a function defined in fns.c.

Signature

(secure-hash ALGORITHM OBJECT &optional START END BINARY)

Documentation

Return the secure hash of OBJECT, a buffer or string.

ALGORITHM is a symbol specifying the hash to use:
- md5 corresponds to MD5, produces a 32-character signature
- sha1 corresponds to SHA-1, produces a 40-character signature
- sha224 corresponds to SHA-2 (SHA-224), produces a 56-character signature
- sha256 corresponds to SHA-2 (SHA-256), produces a 64-character signature
- sha384 corresponds to SHA-2 (SHA-384), produces a 96-character signature
- sha512 corresponds to SHA-2 (SHA-512), produces a 128-character signature

The two optional arguments START and END are positions specifying for which part of OBJECT to compute the hash. If nil or omitted, uses the whole OBJECT.

The full list of algorithms can be obtained with secure-hash-algorithms.

If BINARY is non-nil, returns a string in binary form. In this case, the function returns a unibyte string whose length is half the number of characters it returns when BINARY is nil.

Note that MD5 and SHA-1 are not collision resistant and should not be used for anything security-related. For these applications, use one of the other hash types instead, e.g. sha256 or sha512.

View in manual

Probably introduced at or before Emacs version 24.1.

Source Code

// Defined in /usr/src/emacs/src/fns.c
{
  return secure_hash (algorithm, object, start, end, Qnil, Qnil, binary);
}