https://github.com/sixarm/sixarm_ruby_secure_token
SixArm.com » Ruby » SecureToken class to generate a strong text string
https://github.com/sixarm/sixarm_ruby_secure_token
gem ruby secure security token
Last synced: 4 months ago
JSON representation
SixArm.com » Ruby » SecureToken class to generate a strong text string
- Host: GitHub
- URL: https://github.com/sixarm/sixarm_ruby_secure_token
- Owner: SixArm
- License: other
- Created: 2010-05-25T04:29:36.000Z (about 16 years ago)
- Default Branch: main
- Last Pushed: 2025-04-14T09:21:04.000Z (about 1 year ago)
- Last Synced: 2025-09-05T11:56:24.148Z (10 months ago)
- Topics: gem, ruby, secure, security, token
- Language: Ruby
- Homepage: http://sixarm.com
- Size: 419 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
- Citation: CITATION.cff
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# SixArm.com → Ruby →
SecureToken to generate a random string
[](http://badge.fury.io/rb/sixarm_ruby_secure_token)
[](https://travis-ci.org/SixArm/sixarm_ruby_secure_token)
[](https://codeclimate.com/github/SixArm/sixarm_ruby_secure_token/maintainability)
* Git:
* Doc:
* Gem:
* Contact: Joel Parker Henderson,
* Project: [changes](CHANGES.md), [license](LICENSE.md), [contributing](CONTRIBUTING.md).
## Introduction
This is a secure token generator that creates cryptographically-strong strings.
Example:
SecureToken.new
#=> "kavzwbnxremyqckwtxrumxzapmfmpwve"
For docs go to
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'