https://github.com/tlewin/rtoken
Simple Random Token Generator
https://github.com/tlewin/rtoken
Last synced: 8 months ago
JSON representation
Simple Random Token Generator
- Host: GitHub
- URL: https://github.com/tlewin/rtoken
- Owner: tlewin
- License: other
- Created: 2012-03-02T17:40:27.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2013-10-05T19:10:23.000Z (over 12 years ago)
- Last Synced: 2025-10-16T17:39:40.974Z (8 months ago)
- Language: Ruby
- Homepage:
- Size: 109 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# RToken
Simple Random Token Generator for general purpose.
```ruby
require 'rtoken'
# Generates a random 8 length token with letters and numbers
puts RToken.rtoken
```
Install the gem:
gem install rtoken
## Examples
```ruby
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
```ruby
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