eff_passphrase 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 64a013de2942fc88936bd48c8f9dba5792517cc58f8345ceadf509cbed40ffd0
4
+ data.tar.gz: d90ee3d87be418c363c90b148fe99c803625f8210077b8766cc1f1da79f362bc
5
+ SHA512:
6
+ metadata.gz: 6498b3b39f2281ff62317392b65e1eb6402652186326700ef0a66612e7164ffae8e43672db08c0e5b174dba32ed684dfb1f3a9556cec3444951cd6ea53a7bfb0
7
+ data.tar.gz: 94297d30056efab7b7eec98aed05ac28d6d6a652a7df68ac0e8e674eafda80babdbcf3f9ddcc7e19e13b374dd409687777af9b5078b624bb325f134d41b2cd26
data/CHANGELOG.md ADDED
@@ -0,0 +1 @@
1
+ # ChangeLog
data/LICENSE.txt ADDED
@@ -0,0 +1,5 @@
1
+ Copyright 2023 Instrumentl, Inc.
2
+
3
+ Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
4
+
5
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ This repository contains a very simple Ruby library for using the EFF's [Diceware wordlists](https://www.eff.org/dice) to generate secure passphrases.
2
+
3
+ "EFF®" is a registered trademark of the [Electronic Frontier Foundation](https://www.eff.org/). This repository and project are in no way affiliated by, endorsed by, or associated with the Electronic Frontier Foundation Foundation.
4
+
5
+ ## Usage
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'eff_passphrase'
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install eff_passphrase
22
+ ```
23
+
24
+ ## Invocation
25
+
26
+ ```ruby
27
+ require "eff_passphrase"
28
+
29
+ EffPassphrase.generate(num_words: 6)
30
+ ```
31
+
32
+ This returns an object whose `.to_s` is the raw password, and which includes a helpful `.bits_of_security` field.
33
+
34
+ You can select a wordlist with the `list` kwarg; the following lists are available:
35
+
36
+ - `eff_large_wordlist` (default)
37
+ - `eff_short_wordlist_1` (shorter words; you should use more of them to get the same bits of security)
38
+ - `eff_short_wordlist_2_0` (shorter words; you should use more of them to get the same bits of security)
39
+ - `unsafe_extremely_small` (don't use this except for testing)
@@ -0,0 +1,19 @@
1
+ module EffPassphrase
2
+ module Lists
3
+ LOADED = {}
4
+
5
+ def self.get(list_name)
6
+ unless LOADED.has_key? list_name
7
+ if list_name.include? ".."
8
+ raise "No path injection attacks for you"
9
+ end
10
+
11
+ path = File.expand_path("../../../wordlists/#{list_name}.txt", __FILE__)
12
+ File.open(path) do |f|
13
+ LOADED[list_name] = f.readlines.map { |s| s.strip }
14
+ end
15
+ end
16
+ LOADED[list_name]
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,22 @@
1
+ module EffPassphrase
2
+ class Passphrase
3
+ attr_reader :bits_of_security
4
+
5
+ def initialize(s, bits_of_security)
6
+ @inner = s
7
+ @bits_of_security = bits_of_security
8
+ end
9
+
10
+ def length
11
+ @inner.length
12
+ end
13
+
14
+ def [](i)
15
+ @inner[i]
16
+ end
17
+
18
+ def to_s
19
+ @inner
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EffPassphrase
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,19 @@
1
+ require "eff_passphrase/version"
2
+ require "eff_passphrase/lists"
3
+ require "eff_passphrase/passphrase"
4
+
5
+ require "securerandom"
6
+
7
+ module EffPassphrase
8
+ # Generate a new passphrase from the given list.
9
+ def self.generate(num_words: 6, separator: "-", list: "eff_large_wordlist")
10
+ words = EffPassphrase::Lists.get(list)
11
+ bits_per_word = Math.log(words.length, 2)
12
+ bits_of_security = bits_per_word.floor.to_i * num_words
13
+ s_passphrase = num_words.times.map do
14
+ index = SecureRandom.random_number(0...words.length)
15
+ words[index]
16
+ end.join(separator)
17
+ EffPassphrase::Passphrase.new(s_passphrase, bits_of_security)
18
+ end
19
+ end
metadata ADDED
@@ -0,0 +1,55 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: eff_passphrase
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Instrumentl, Inc.
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-01-10 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: |2
14
+ Library for using the EFF's list of Engliush passphrase words to generate
15
+ a Diceware-style passphrase
16
+ email:
17
+ - oss@instrumentl.com
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - CHANGELOG.md
23
+ - LICENSE.txt
24
+ - README.md
25
+ - lib/eff_passphrase.rb
26
+ - lib/eff_passphrase/lists.rb
27
+ - lib/eff_passphrase/passphrase.rb
28
+ - lib/eff_passphrase/version.rb
29
+ homepage: https://github.com/instrumentl/eff_passphrase
30
+ licenses:
31
+ - ISC
32
+ metadata:
33
+ homepage_uri: https://github.com/instrumentl/eff_passphrase
34
+ source_code_uri: https://github.com/instrumentl/eff_passphrase
35
+ changelog_uri: https://github.com/instrumentl/eff_passphrase/blob/main/CHANGELOG.md
36
+ post_install_message:
37
+ rdoc_options: []
38
+ require_paths:
39
+ - lib
40
+ required_ruby_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: 2.7.0
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ requirements: []
51
+ rubygems_version: 3.3.26
52
+ signing_key:
53
+ specification_version: 4
54
+ summary: Library for generating passphrases
55
+ test_files: []