Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xuanxu/random_sources
Ruby gem to generate random numbers from web providers of real randomness sources like radioactive decay or atmospheric noise.
https://github.com/xuanxu/random_sources
Last synced: 25 days ago
JSON representation
Ruby gem to generate random numbers from web providers of real randomness sources like radioactive decay or atmospheric noise.
- Host: GitHub
- URL: https://github.com/xuanxu/random_sources
- Owner: xuanxu
- License: mit
- Created: 2010-08-10T13:26:12.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2020-04-12T19:07:21.000Z (over 4 years ago)
- Last Synced: 2024-03-15T13:09:44.313Z (10 months ago)
- Language: Ruby
- Homepage: http://github.com/xuanxu/random_sources
- Size: 55.7 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.rdoc
- License: MIT-LICENSE.txt
Awesome Lists containing this 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:
- {Random.org}[https://www.random.org/]
- {Fourmilab's Hotbits}[https://www.fourmilab.ch/hotbits/]{}[http://travis-ci.org/xuanxu/random_sources]
{}[http://badge.fury.io/rb/random_sources]== Getting started
Install the gem:
$ [sudo] gem install random_sourcesThen 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' #=>
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}[https://github.com/xuanxu/random_sources/wiki]
== Credits
Author:: Juanjo Bazán
Copyright:: Copyright (c) 2010 - ∞ Juanjo Bazán
License:: Released under the {MIT license}[https://github.com/xuanxu/random_sources/blob/master/MIT-LICENSE.txt].