Navigation Menu

Skip to content

SixArm/sixarm_ruby_secure_token

Repository files navigation

SixArm.com → Ruby →
SecureToken to generate a random string

Gem Version Build Status Code Climate

Introduction

This is a secure token generator that creates cryptographically-strong strings.

Example:

SecureToken.new  
#=> "kavzwbnxremyqckwtxrumxzapmfmpwve"

For docs go to http://sixarm.com/sixarm_ruby_secure_token/doc

Want to help? We're happy to get pull requests.

Install

Gem

To install this gem in your shell or terminal:

gem install sixarm_ruby_secure_token

Gemfile

To add this gem to your Gemfile:

gem 'sixarm_ruby_secure_token'

Require

To require the gem in your code:

require 'sixarm_ruby_secure_token'

Details

This generates a 32-character token of lowercase letters.

This uses Ruby's SecureRandom methods for strong security.

SecureToken is a string, so you can do any string methods on it.

You can change how tokens are randomly created by using cusomtization.

Customization

To customize the choices:

SecureToken.choices = ['a','b','c']
SecureToken.new 
#=> "acbbaccbabcabcabbcabcabcdbbcabcb"

To customize the length:

SecureToken.length = 8
SecureToken.new 
#=> "kavzwbnx"

The default length is 32.

The default choices are the lowercase English letters 'a' to 'z', but omitting the letters 'i', 'l', 'o', 'q'. We omit these because our user testing shows these characters are often misunderstood by users.

Enumeration

To use an enumeration #next method:

s = SecureToken.new
s.next  #=> 'bacbaacb'

About

SixArm.com » Ruby » SecureToken class to generate a strong text string

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages