0.0
No commit activity in last 3 years
No release in over 3 years
The Random Sources library provides genuine random numbers, generated by processes fundamentally governed by inherent uncertainty instead of some pseudo-random number algorithm. It uses http services from different online providers.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
 Project Readme

Random Sources¶ ↑

Random Sources is a Ruby gem that provides genuine random numbers, generated by processes fundamentally governed by inherent uncertainty instead of some pseudo-random number algorithm. It uses services from different online providers.

Current supported random numbers providers:

<img src=“https://secure.travis-ci.org/xuanxu/random_sources.png?branch=master” alt=“Build status” /> <img src=“https://badge.fury.io/rb/random_sources.png” alt=“Gem Version” />

Getting started¶ ↑

Install the gem:

$ [sudo] gem install random_sources

Then depending on your project you may:

Require the gem directly:

require 'random_sources'

or add it to your Gemfile:

gem 'random_sources', git: 'git://github.com/xuanxu/random_sources.git'

Usage¶ ↑

Your entry point is the RandomSources module. With it you can get a list of supported providers and instantiate any of them:

RandomSources.list                   #=> "HotBits, RandomOrg"

RandomSources.generator 'RandomOrg'  #=> <RandomSources::RandomOrg>

Once you have your generator you can ask for the random bytes:

generator = RandomSources.generator 'RandomOrg'

# five integers between 1 and 100:
generator.integers(num: 5, min: 1, max: 100)
# => [45, 61, 22, 96, 70]

# two strings of 10 unique characters including digits and uppercase letters:
generator.strings(num: 2, unique: 'on', digits: 'on', upperalpha: 'on', loweralpha: 'off')
# => ["6ESR61Y1", "K7520E6L"]

You can get integers, strings, sequences, bytes, etc… For a list of all the options of any supported source, check the doc in the wiki

Credits¶ ↑

Author

Juanjo Bazán

Copyright

Copyright © 2010 - ∞ Juanjo Bazán

License

Released under the MIT license.