Project

rtoken

0.0
No commit activity in last 3 years
No release in over 3 years
RToken generates random tokens, of any length, for multiple purposes, ex: web urls, data identification, etc.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

RToken

Simple Random Token Generator for general purpose.

require 'rtoken'
    
# Generates a random 8 length token with letters and numbers
puts RToken.rtoken 

Install the gem:

gem install rtoken

Examples

require 'rtoken'

# Generates a random 16 length token with letters and numbers 
# and some special chars
RToken.rtoken(:size => 16, :special_chars => '!@#$%')

# Generates a random 32 length token with ONLY letters
RToken.rtoken(:size => 32, :numeric => false)

# Generates a random token with all lowercase chars
RToken.rtoken(:size => 32, :numeric => false, :lowercase => true)

It is possible to create an instance with predefined options

require 'rtoken'

rtkn = RToken.new(:size => 10, :special_chars => '+-*/')

# All subsequent calls will keep the same options
rtkn.rtoken #=> Random 10 length token with special chars

# It is possible to make individual changes
rtkn.rtoken :size => 4 #=> Random 4 length token with special chars
rtkn.rtoken 4 # Less verbose fashion

Command line

RToken include interface for command line token generation.

It's handfull for creation of password, secret keys, etc.

Usage: rtoken [options]
    -s, --size TOKEN_SIZE            token size (default 8)
    -U, --uppercase                  only uppercase chars (default false)
    -l, --lowercase                  only lowercase chars (default false)
    -n, --[no]-numeric               allow numeric chars [0-9] (default true)
    -p, --special CHARS              include special chars
    -c, --clipboard                  copy token to the clipboard (default false)
    -h, --help                       show this message