{string2id:string}

Description

Converts any string into an AA item id - a 32-character lowercase hexadecimal long (unpacked) id. It is the template counterpart of AA core string2id() function. The id is built from the MD5 hash of the input, so the same string always produces the same id (the mapping is deterministic, never random). Use it to derive a stable, collision-resistant id from arbitrary text, or to compare two strings by comparing their ids. AA uses it internally to mint item ids for fed items, by hashing the source item id together with the target slice id. The hash is sanitized for AA binary id packing: if the raw MD5 would contain the byte pair 00 (a string terminator), 27 (a packed quote), or 20 (a space, which MySQL trims) at position 30, the function appends a space to the input and re-hashes until the result is safe - so for some inputs the id is not the plain MD5, yet it is still fully deterministic. One parser trap: a sole argument of the single character 0 is read as no argument, so it hashes the empty string; pass 00 to hash a literal zero.

Parameters

string required

The text to convert into an id. Any string is accepted, and the same input always yields the same id. An empty string still produces a valid id. A sole argument of the single character 0 is read as no argument (so it behaves like an empty input); pass 00 to hash a literal zero. The input is not trimmed, so a trailing space changes the id.

Examples

test{string2id:hello}
Expected5d41402abc4b2a76b9719d911017c592
Actual5d41402abc4b2a76b9719d911017c592
The id of the word hello. Here the result equals the plain MD5 hash, because that hash contains none of the forbidden byte pairs.
test{string2id:actionapps}
Expected9626203da9b4b8b3021dd99fd3662c30
Actual9626203da9b4b8b3021dd99fd3662c30
Any text works as input. The same input always produces the same id, so you can use it to derive a stable id from a name, a URL, or any other string.
test{string2id:}
Expected7215ee9c7d9dc229d2921a40e899ec5f
Actual7215ee9c7d9dc229d2921a40e899ec5f
An empty input still yields a valid 32-character id. MD5 of the empty string contains 00, so the function re-hashes once with a trailing space; a single space gives the same id.
test{string2id:00}
Expectedb4b147bc522828731f1a016bfa72c073
Actualb4b147bc522828731f1a016bfa72c073
Passing 00 hashes the literal two-character string 0 0 (the parser quirk only swallows a lone single 0). This is the id of a real zero value, distinct from the empty-input id.
test{ifeq:{string2id:apc}:{string2id:apc}:same:different}
Expectedsame
Actualsame
The mapping is deterministic, not random: hashing the same string twice gives identical ids, so the comparison reports same. This is what makes the id usable as a content-derived key.
test{string2id:0}
Expected7215ee9c7d9dc229d2921a40e899ec5f
Actual7215ee9c7d9dc229d2921a40e899ec5f
Trap: a sole argument of the single character 0 is read by the parser as no argument at all, so this behaves like the empty input above. To hash a literal zero, pass 00 - see the next example.
test{string2id:2026-06-04}
Expectedc48dd2c747e8b252b082d4d20f97e9fd
Actualc48dd2c747e8b252b082d4d20f97e9fd
For this input the result is NOT the plain MD5. The raw MD5 contained a forbidden byte pair, so the function appended a space and re-hashed until the id was safe for AA binary id packing. The id is still deterministic - it does not change between calls.