hash()
Returns the result of performing the unidirectional hash algorithm as a binary value.
Syntax
hash(HASH_ALGO, BIN_DATA)
Required Parameter
HASH_ALGO
- Hash algorithm (
md5
,sha1
,sha256
,sha384
, andsha512
). BIN_DATA
- Data to be hashed. The data MUST be in binary form. The function returns null if a non-binary value is received.
Usage
json "{}"
| eval hash=hash("md5", binary("hello, world!"))
=> 3adbbad1791fbae3ec908894c4963870
json "{}"
| eval hash=hash("sha1", binary("hello, world!"))
=> 1f09d30c707d53f3d16c530dd73d70a6ce7596a9
json "{}"
| eval hash=hash("sha256", binary("hello, world!"))
=> 68e656b251e67e8358bef8483ab0d51c6619f3e7a1a9f0e75838d41ff368f728
json "{}"
| eval hash=hash("sha384", binary("hello, world!"))
=> fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd
json "{}"
| eval hash=hash("sha512", binary("hello, world!"))
=>
6c2618358da07c830b88c5af8c3535080e8e603c88b891028a259ccdb9ac802d0fc0170c99d58affcf00786ce188fc5d753e8c6628af2071c3270d50445c4b1c
json "{}" | eval hash=hash("md5", "hello world") => null
json "{}" | eval hash=hash("sha1", null) => null
json "{}" | eval hash=hash("sha1", 1234) => null