Hashes a string with the named algorithm and returns the digest as hex. Supported algorithms are the common SHA family; a keyed digest belongs to crypt.hmac, not here.

Parameters

string
required
The string to digest.
string
required
The hash algorithm, e.g. “sha256”.

Returns

string
The hex digest.

Example

Errors

  • hmac: a keyed digest.