Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/soveran/stringent
Generate a string with a target entropy
https://github.com/soveran/stringent
Last synced: 3 months ago
JSON representation
Generate a string with a target entropy
- Host: GitHub
- URL: https://github.com/soveran/stringent
- Owner: soveran
- License: mit
- Created: 2015-07-14T16:03:23.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-07-15T06:51:45.000Z (over 9 years ago)
- Last Synced: 2024-07-22T16:05:07.516Z (3 months ago)
- Language: Ruby
- Size: 125 KB
- Stars: 12
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG
- Contributing: CONTRIBUTING
- License: LICENSE
Awesome Lists containing this 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:```ruby
>> Stringent.generate
=> "kEPcWwph6OkyHIKZtw4DwnWnlJo0Q6QoDp8Iykshrfm"
```Generate a random string with a custom target entropy:
```ruby
>> Stringent.generate(entropy: 32)
=> "Kqd6e0"
```Generate a random string with a custom target entropy and a custom
table:```ruby
>> Stringent.generate(entropy: 16, table: "01")
=> "1000100110000000"
```Installation
------------```
$ gem install stringent
```