SHA1, SHA256 and SHA512

Learn about the SHA1, SHA256 and SHA512 OTTL converter function.

The SHA converters hash a string using the SHA-1, SHA-256 or SHA-512 hashing algorithm.

Syntax: SHA1|SHA256|SHA512(value)

  • value: the bracket notation location of the string field to hash

These functions are useful for data masking, anonymization, and generating unique identifiers.

Input

{
	"_type": "log",
	"body": {
		"test_string": "hello",
		"run": 23
	},
	"resource": {...},
	"timestamp": 1727750400000
}

Statement

set(body["sha1"], SHA1(body["test_string"]))
set(body["sha256"], SHA256(body["test_string"]))
set(body["sha512"], SHA512(body["test_string"]))

Output

{
	"_type": "log",
	"body": {
		"test_string": "hello",
		"sha1": "aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d",
		"sha256": "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824",
		"sha512": "9b71d224bd62f3785d96d46ad3ea3d73319bfbc2890caadae2dff72519673ca72323c3d99ba5c11d7c7acc6e14b8c5da0c4663475c2e5c3adef46f73bcdec043",
		"run": 23
	},
	"resource": {...},
	"timestamp": 1727750400000
}

The string “hello” was hashed using SHA-1, SHA-256, and SHA-512 algorithms, producing cryptographically secure hash values.