Name
tree_sha1, tree_hmac — compute SHA-1 digest or HMAC over an arbitrary boxed value tree
Synopsis
varchar tree_sha1(
|
in value any, |
in hex_output integer); |
varchar tree_hmac(
|
in value any, |
| in key varchar, | |
| in algorithm integer, | |
in hex_output integer); |
Description
Unlike
sha1_digest
which only accepts a flat string argument, the tree_*
functions recursively walk any Virtuoso boxed value (string, number,
vector, array, even a parsed XML tree) and feed its canonical in-memory
representation to the digest algorithm. They are useful for fingerprinting
arbitrary SQL or SPARQL values regardless of shape.
tree_sha1 returns the SHA-1 digest of
value. When the optional
hex_output argument is non-zero the digest is
returned as a 40-character lowercase hexadecimal string; otherwise it is
returned as a raw 20-byte binary string.
tree_hmac returns a keyed-hash message authentication
code over value using the secret
key. The optional algorithm
argument selects the underlying digest (0 = default SHA-1; other values
select the alternative digests supported by the linked OpenSSL build, see
box_hmac in the server source).
hex_output behaves as for
tree_sha1. Returns SQL NULL if the algorithm is
unavailable.