Skip to main content
Version: v1.7.0

ksuid

Function

ksuid encode/decode KSUID-style unique identifiers

Synopsis

ksuid() -> bytes
ksuid(b: bytes) -> string
ksuid(s: string) -> bytes

Description

The ksuid function either encodes a KSUID (a byte sequence of length 20) b into a Base62 string or decodes a KSUID Base62 string into a 20-byte Zed bytes value.

If ksuid is called with no arguments, a new KSUID is generated and returned as a bytes value.

Example:

echo  '{id:0x0dfc90519b60f362e84a3fdddd9b9e63e1fb90d1}' | zq -z 'id := ksuid(id)' -

=>

{id:"1zjJzTWWCJNVrGwqB8kZwhTM2fR"}