Skip to content

Ruby implementation of Nanoid, secure URL-friendly unique ID generator

License

Notifications You must be signed in to change notification settings

radeno/nanoid.rb

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nanoid.rb

A tiny, secure URL-friendly unique string ID generator.

Ruby implementation of original NanoID https://github.com/ai/nanoid

Installation

Into Gemfile / gems.rb add:

gem 'nanoid'

Usage

Default settings:

Size: 21 character length

Alphabet: _~0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ

Simple generate unique string:

require 'nanoid'

Nanoid.generate

Change length of generated string

require 'nanoid'

Nanoid.generate(size: 10)

Change alphabet of generated string

require 'nanoid'

Nanoid.generate(alphabet: '1234567890abcdef')

Change size and alphabet of generated string

require 'nanoid'

Nanoid.generate(size: 14, alphabet: '1234567890abcdef')

About

Ruby implementation of Nanoid, secure URL-friendly unique ID generator

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages