Generate a UUID in Larzscript
Generate random (v4) and time-sortable (v7, ULID, nanoid) unique identifiers.
v7/ULID matter for anything that writes a lot of ids into a database index: sorting a batch of them as plain strings also sorts them by creation time, which a random v4 id can't do.
larzscript pkg install uuid
Code
import "uuid" as uuid print(uuid.v4()) print(uuid.v7()) print(uuid.ulid()) print(uuid.nanoid())
Output
1e3b4dae-4c82-494e-a25b-4a26d0cf5dd7 019fc342-c9d0-7d2a-9f5a-dbe9710e80f6 01KZ1M5JEGC1GZA4MTS5STQY6V 0Nb1rFbSIrUBVz2U6d0ee
Related
larzuuidRFC 4122 v4 UUID generation→Make an HTTP GET Request in LarzscriptFetch a URL and read its status code and body - or parse a JSON API response directly.→Sign and Verify a Webhook Payload in LarzscriptSign an outgoing webhook payload with HMAC-SHA256, and verify an incoming one - the same shape real payment/webhook providers use.→Hash Data with SHA-256 in LarzscriptCompute a real SHA-256 hash and an HMAC-SHA256 message authentication code.→