18.3.2. Hashing
Hashing functions are exposed to Lua scripts with suricata.hashing
library. For example:
local hashing = require("suricata.hashing")
18.3.2.1. SHA-256
18.3.2.1.1. sha256_digest(string)
SHA-256 hash the provided string returning the digest as bytes.
18.3.2.1.2. sha256_hex_digest(string)
SHA-256 hash the provided string returning the digest as a hex string.
18.3.2.1.3. sha256()
Returns a SHA-256 hasher that can be updated multiple times, for example:
local hashing = require("suricata.hashing")
hasher = hashing.sha256()
hasher.update("www.suricata")
hasher.update(".io")
hash = hasher.finalize_to_hex()
The methods on the hasher object include:
update(string)
: Add more data to the hasherfinalize()
: Finalize the hash returning the hash as a byte stringfinalize_to_hex()
: Finalize the hash returning the has as a hex string
18.3.2.2. SHA-1
18.3.2.2.1. sha1_digest(string)
SHA-1 hash the provided string returning the digest as bytes.
18.3.2.2.2. sha1_hex_digest(string)
SHA-1 hash the provided string returning the digest as a hex string.
18.3.2.2.3. sha1()
Returns a SHA-1 hasher that can be updated multiple times, for example:
local hashing = require("suricata.hashing")
hasher = hashing.sha1()
hasher.update("www.suricata")
hasher.update(".io")
hash = hasher.finalize_to_hex()
The methods on the hasher object include:
update(string)
: Add more data to the hasherfinalize()
: Finalize the hash returning the hash as a byte stringfinalize_to_hex()
: Finalize the hash returning the has as a hex string
18.3.2.3. MD5
18.3.2.3.1. md5_digest(string)
MD5 hash the provided string returning the digest as bytes.
18.3.2.3.2. md5_hex_digest(string)
MD5 hash the provided string returning the digest as a hex string.
18.3.2.3.3. md5()
Returns a MD5 hasher that can be updated multiple times, for example:
local hashing = require("suricata.hashing")
hasher = hashing.md5()
hasher.update("www.suricata")
hasher.update(".io")
hash = hasher.finalize_to_hex()
The methods on the hasher object include:
update(string)
: Add more data to the hasherfinalize()
: Finalize the hash returning the hash as a byte stringfinalize_to_hex()
: Finalize the hash returning the hash as a hex string