https://github.com/sixarm/sixarm_ruby_secure_random
SixArm.com » Ruby » secure random number generator interface for Ruby 1.8.6 backported from 1.8.7
https://github.com/sixarm/sixarm_ruby_secure_random
gem random ruby secure security
Last synced: over 1 year ago
JSON representation
SixArm.com » Ruby » secure random number generator interface for Ruby 1.8.6 backported from 1.8.7
- Host: GitHub
- URL: https://github.com/sixarm/sixarm_ruby_secure_random
- Owner: SixArm
- License: other
- Created: 2010-05-25T04:32:17.000Z (about 16 years ago)
- Default Branch: main
- Last Pushed: 2023-09-15T19:29:01.000Z (almost 3 years ago)
- Last Synced: 2025-02-06T00:24:22.313Z (over 1 year ago)
- Topics: gem, random, ruby, secure, security
- Language: Ruby
- Homepage: http://sixarm.com
- Size: 328 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# SixArm.com → Ruby →
SecureRandom gem number generator for Ruby 1.8.6, backported from 1.8.7
* Doc:
* Gem:
* Repo:
## Introduction
This library is an interface for secure random number generator which is
suitable for generating session key in HTTP cookies, etc.
## Install
### Gem
To install this gem in your shell or terminal:
gem install sixarm_ruby_secure_random
### Gemfile
To add this gem to your Gemfile:
gem 'sixarm_ruby_secure_random'
### Require
To require the gem in your code:
require 'sixarm_ruby_secure_random'
## Details
This gem is a backport of the built-in secure random method from Ruby 1.8.7, and is only intended for use with Ruby 1.8.6 and earlier.
This supports following secure random number generators.
* openssl
* /dev/urandom
## Examples
Generate hex:
SecureRandom.hex(10) => "52750b30ffbc7de3b362"
SecureRandom.hex(10) => "92b15d6c8dc4beb5f559"
SecureRandom.hex(11) => "6aca1b5c58e4863e6b81b8"
SecureRandom.hex(12) => "94b2fff3e7fd9b9c391a2306"
SecureRandom.hex(13) => "39b290146bea6ce975c37cfc23"
Generate base64:
SecureRandom.base64(10) => "EcmTPZwWRAozdA=="
SecureRandom.base64(10) => "9b0nsevdwNuM/w=="
SecureRandom.base64(10) => "KO1nIU+p9DKxGg=="
SecureRandom.base64(11) => "l7XEiFja+8EKEtY="
SecureRandom.base64(12) => "7kJSM/MzBJI+75j8"
SecureRandom.base64(13) => "vKLJ0tXBHqQOuIcSIg=="
Generate bytes:
SecureRandom.random_bytes(10) => "\016\t{\370g\310pbr\301"
SecureRandom.random_bytes(10) => "\323U\030TO\234\357\020\a\337"
## More
For docs go to
Want to help? We're happy to get pull requests.