A simple, fast, and concurrent command-line tool for generating secure, URL-friendly unique string IDs using the NanoID Go implementation.
- Customizable Length: Specify the length of the generated Nano ID.
- Custom Alphabet: Define your own set of characters for ID generation.
- Multiple ID Generation: Generate multiple IDs in a single command.
- Verbose Mode: Enable detailed logs during ID generation.
Cosign is used to sign releases for integrity verification.
To verify the integrity of the release, you can use Cosign to check the signature and checksums. Follow these steps:
# Fetch the latest release tag from GitHub API (e.g., "v1.39.0")
TAG=$(curl -s https://api.github.com/repos/sixafter/nanoid-cli/releases/latest | jq -r .tag_name)
# Remove leading "v" for filenames (e.g., "v1.39.0" -> "1.39.0")
VERSION=${TAG#v}
# Verify the release tarball
cosign verify-blob \
--key https://raw.githubusercontent.com/sixafter/nanoid-cli/main/cosign.pub \
--signature nanoid-${VERSION}.tar.gz.sig \
nanoid-${VERSION}.tar.gz
# Download checksums.txt and its signature from the latest release assets
curl -LO https://github.com/sixafter/nanoid-cli/releases/download/${TAG}/checksums.txt
curl -LO https://github.com/sixafter/nanoid-cli/releases/download/${TAG}/checksums.txt.sig
# Verify checksums.txt with cosign
cosign verify-blob \
--key https://raw.githubusercontent.com/sixafter/nanoid-cli/main/cosign.pub \
--signature checksums.txt.sig \
checksums.txtIf valid, Cosign will output:
Verified OKgit clone https://github.com/sixafter/nanoid-cli.git
cd nanoid-cli
make buildThis command compiles the main.go file and produces an executable named nanoid in the ./out directory.
brew tap sixafter/tap
brew install --cask nanoidFor casks to work, you'll need curl installed. If you don't have it, you can install it with:
brew install curlNote for macOS users: If you see a killed error when running nanoid, macOS may have quarantined the binary due to it being unsigned or unnotarized. To resolve:
sudo xattr -d com.apple.quarantine /opt/homebrew/bin/nanoidRun the CLI to Generate a Default Nano ID:
nanoid generateOutput:
V1StGXR8_Z5jdHi6B-myTGenerate a Nano ID with a Custom Length:
nanoid generate --length 30Output:
mJzY8fK3Lq7B9sR2dT4hV5nG1aC0eXGenerate a Nano ID with a Custom Alphabet:
nanoid generate --alphabet "abcdef123456"Output:
1a2b3c4d5e6f1a2b3c4d5e6f1a2b3c4Generate Multiple Nano IDs with verbose output:
nanoid generate --count 10 --verboseOutput:
_OKhyfsfINNfokJZxyj4j
HZUZ7sTHlLpub0rryyLsr
_agY2S55BoYSdipGVaL4P
FgrdoVAzzFZWS2bc42bre
saM2-PnvwIIyt312rkGbS
RCdECZCOr7VTkGXx5CoQo
bCX2GTzXJ22Azn0MAYkQ3
Fh7-65FYU9Higp7scLBht
uC87QtpSLb8ZX5oENCHJP
bTPg9AynQtzldZazM-wKV
Start Time..............: 2025-04-14T16:30:03-05:00
Total IDs generated.....: 10
Total time taken........: 46.959µs
Average time per ID.....: 4.695µs
Throughput..............: 212951.72 IDs/sec
Estimated output size...: 220 B
Estimated entropy per ID: 126.00 bits
Memory used.............: 0.32 MiBContributions are welcome. See CONTRIBUTING
This project is licensed under the Apache 2.0 License. See LICENSE file.