File tree Expand file tree Collapse file tree 6 files changed +130
-0
lines changed Expand file tree Collapse file tree 6 files changed +130
-0
lines changed Original file line number Diff line number Diff line change
1
+ .rvmrc
Original file line number Diff line number Diff line change
1
+ source :rubygems
2
+
3
+ gem 'bundler' , '~> 1.0'
4
+
5
+ gemspec
Original file line number Diff line number Diff line change
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ spass (0.0.1 )
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.1.3 )
10
+ rcov (0.9.11 )
11
+ rspec (2.7.0 )
12
+ rspec-core (~> 2.7.0 )
13
+ rspec-expectations (~> 2.7.0 )
14
+ rspec-mocks (~> 2.7.0 )
15
+ rspec-core (2.7.1 )
16
+ rspec-expectations (2.7.0 )
17
+ diff-lcs (~> 1.1.2 )
18
+ rspec-mocks (2.7.0 )
19
+
20
+ PLATFORMS
21
+ ruby
22
+
23
+ DEPENDENCIES
24
+ bundler (~> 1.0 )
25
+ rcov
26
+ rspec (>= 2.2.0 )
27
+ spass !
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'spass' # Is this needed?
4
+
5
+ USAGE = <<EOF
6
+ makepass.rb: Generate a passphrase with lowercase words
7
+
8
+ Usage:
9
+
10
+ $ makepass.rb <length>
11
+
12
+ This script generates a plain-English passphrase of at least the given length
13
+ (in characters), using random words from /usr/share/dict/words. Only lowercase
14
+ letters a-z will be included in the output, making passphrases relatively easy
15
+ to type (though usually nonsensical).
16
+
17
+ Examples:
18
+
19
+ $ ./makepass.rb 12
20
+ hive frighten
21
+
22
+ $ ./makepass.rb 24
23
+ moppet castigator harvesters
24
+
25
+ $ ./makepass.rb 32
26
+ munificent icebound raymond clorets
27
+
28
+ A 32-character passphrase has about 120 bits of entropy, which is overkill for
29
+ most purposes. A 24-character passphrase clocks in at about 90 bits of entropy,
30
+ suitable for most high-security applications like root passwords or financial
31
+ records. You might want to use a password checker to verify the strength of
32
+ your passphrase after generating one that you like:
33
+
34
+ http://rumkin.com/tools/password/passchk.php
35
+
36
+ Inspired by http://xkcd.com/936/
37
+ EOF
38
+
39
+ if ARGV . count == 0
40
+ puts USAGE
41
+ else
42
+ length = ARGV [ 0 ] . to_i
43
+ puts SPass ::generate ( length )
44
+ end
45
+
46
+
Original file line number Diff line number Diff line change
1
+ DICT_PATH = '/usr/share/dict/words'
2
+ DICT_LINES = `wc -l #{ DICT_PATH } ` . split . first . to_i
3
+
4
+ class SPass
5
+ # Return a random word from the dictionary, lowercased
6
+ def self . random_word
7
+ %x[sed -n '#{ rand ( DICT_LINES ) } {p;q;}' '#{ DICT_PATH } '] . chomp . downcase
8
+ end
9
+
10
+ # Return a random word that consists of only lowercase letters
11
+ def self . random_ascii_word
12
+ word = random_word
13
+ while word =~ /[^a-z]/
14
+ word = random_word
15
+ end
16
+ return word
17
+ end
18
+
19
+ # Generate a passphrase of at least the given length in characters
20
+ def self . generate ( length )
21
+ phrase = ''
22
+ while phrase . length < length
23
+ phrase += random_ascii_word + ' '
24
+ end
25
+ return phrase . chomp
26
+ end
27
+ end
28
+
Original file line number Diff line number Diff line change
1
+ Gem ::Specification . new do |s |
2
+ s . name = "spass"
3
+ s . version = "0.0.1"
4
+ s . summary = "Generate passphrases"
5
+ s . description = <<-EOS
6
+ spass generates passphrases using random words
7
+ EOS
8
+ s . authors = [ "Eric Pierce" ]
9
+
10
+ s . homepage = "http://github.com/wapcaplet/spass"
11
+ s . platform = Gem ::Platform ::RUBY
12
+
13
+ s . add_development_dependency 'rspec' , '>= 2.2.0'
14
+ s . add_development_dependency 'rcov'
15
+ #s.add_development_dependency 'yard'
16
+ #s.add_development_dependency 'bluecloth'
17
+
18
+ s . files = `git ls-files` . split ( "\n " )
19
+ s . require_path = 'lib'
20
+
21
+ s . executables = [ 'spass' ]
22
+ end
23
+
You can’t perform that action at this time.
0 commit comments