Browse the docs

randomID

A random ID from the Mac's secure random source.

Details #

randomID(length?, alphabet?) makes a random ID: 12 characters by default from letters, digits, - and _ (safe in a link). Give another length (1 to 1024) or your own characters, such as randomID(6, "0123456789"). It uses SecRandomCopyBytes, evenly, with no bias.

Parameters #

Takes 0 to 2 arguments. {{ randomID(text?, b?) }}

Examples #

randomID()
→ omaLYHJeM8Uv
randomID(6, "0123456789")
→ 047506

Gotchas #

  • The alphabet needs at least two different characters.

  • Each call is different, so a preview does not show a sample.