Project

stringent

0.0
No commit activity in last 3 years
No release in over 3 years
Generate a string with a target entropy
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

>= 0
 Project Readme

Stringent

Generate a string with a target entropy

Description

Stringent uses SecureRandom to generate a pseudo-random number with a target entropy, and proceeds to encode it with a given table of symbols. The target entropy defaults to 256 bits, and the table of symbols defaults to case sensitive alphanumeric characters. Both values can be passed as parameters.

The entropy parameter means that there are 2^entropy possible outputs for a given call. However, it does not mean that each bit is actually generated using one bit of entropy, since SecureRandom may use /dev/urandom which, while unguessable, may have less than 1 bit of entropy for each bit of output.

Usage

Generate a random string with the default values for target entropy and symbols table:

>> Stringent.generate
=> "kEPcWwph6OkyHIKZtw4DwnWnlJo0Q6QoDp8Iykshrfm"

Generate a random string with a custom target entropy:

>> Stringent.generate(entropy: 32)
=> "Kqd6e0"

Generate a random string with a custom target entropy and a custom table:

>> Stringent.generate(entropy: 16, table: "01")
=> "1000100110000000"

Installation

$ gem install stringent