Nanoid in Janet
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Jason Staten d0dbc03124
4 years ago
test non-secure variant 4 years ago
.build.yml build: janet-lang dependency 4 years ago
LICENSE first 4 years ago docs and stats 4 years ago
nanoid.janet docs and stats 4 years ago
project.janet 0.1.1 4 years ago

janet-nanoid status License: Unlicense

A library for generating random IDs.

Ported implementation of nanoid in Janet.


jpm install


nanoid comes with two variants gen and gen-non-secure.

gen relies on Janet's os/cryptorand to obtain cryptographically secure random bytes.

gen-non-secure uses the math/rng pseudorandom generator.


  • :size - Length of the output string (default 21)
  • :alphabet - Alphabet of characters to use (defaults alphanumeric and -_)
  • :rng - math/rng instance to generate (gen-non-secure only)


(import nanoid)

# "xo25OEhGZ7yoHYbfPpmZE"

(nanoid/gen :size 5)
# "U5bBu"

(nanoid/gen :alphabet "abcd1234")
# "24234a13a4ddddc3dbb4a"

(nanoid/gen-non-secure :size 5)
# "vWgzu"