dicemypass 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,79 @@
1
+ require 'thor'
2
+ require 'dicemypass'
3
+ require 'colorize'
4
+ require 'clipboard'
5
+
6
+ module Dicemypass
7
+ class CLI < Thor
8
+ default_task :gen_pass
9
+ desc 'gen [length]', 'Generate a passphrase of the desired length.'
10
+ method_option :clipboard,
11
+ aliases: '-c',
12
+ type: :boolean,
13
+ desc: 'Copy passphrase to clipboard.'
14
+ method_option :hibp,
15
+ aliases: '-H',
16
+ type: :boolean,
17
+ desc: 'Check if passphrase is vulnerable in HIBP database.'
18
+ def gen_pass(pass_length = 7)
19
+ # Force our length value to be an integer
20
+ new_passphrase = Dicemypass.gen_passphrase(pass_length.to_i)
21
+
22
+ # If our options :clipboard and :hibp are true, then proceeds
23
+ # to copy the contents of the passphrase to the clipboard
24
+ # and check if the passphrase is vulnerable.
25
+ Clipboard.copy(new_passphrase.join(' ')) if options[:clipboard]
26
+ dataset_count = Dicemypass.check_pwned(new_passphrase) if options[:hibp]
27
+
28
+ # To add colors, first we store the available colors in a variable
29
+ # but we eliminate the color black which makes some words to be
30
+ # unreadable in the terminal. After that, we map the passphrase list
31
+ # and assign a random color to each one of them.
32
+ colors = String.colors
33
+ colors.delete(:black) # black color looks ugly in the terminal
34
+ new_passphrase.map! do |phrase|
35
+ random_color = colors.sample
36
+ phrase.colorize(random_color)
37
+ end
38
+ # We add default messages in case our options are activated. A green bold
39
+ # message when the user wants to copy the passphrase, another one if the
40
+ # passphrase is safe, and a red bold one if the passphrase is vulnerable.
41
+ copy_msg = '- Copied to clipboard.'.bold.green
42
+ vuln_pass_msg = "- WARNING: Passphrase appears in #{dataset_count} datasets!".red.bold
43
+ safe_pass_msg = '- Password was not found in a dataset.'.green.bold
44
+
45
+ # Bold the title passphrase and then join the passphrase to make it a string.
46
+ puts '- Passphrase: '.bold + new_passphrase.join(' ')
47
+
48
+ # If the clipboard option is active then display the clipboard message
49
+ puts copy_msg if options[:clipboard]
50
+ # If the option :hibp is True then check if the pass is found in a dataset.
51
+ # If dataset_cout is not nil then display vuln_pass_msg, else display
52
+ # the safe_pass_msg.
53
+ puts dataset_count ? vuln_pass_msg : safe_pass_msg if options[:hibp]
54
+ end
55
+
56
+ desc 'check', 'Check if a password/passphrase is vulnerable.'
57
+ def check_pass
58
+ puts "Enter your password, press ENTER when you're done."
59
+ password = ask('Password (hidden):'.yellow, echo: false)
60
+ (puts "Aborted.".red.bold; exit) if password.empty?
61
+
62
+
63
+ dataset_count = Dicemypass.check_pwned(password)
64
+ vuln_msg = "Your password appears in #{dataset_count} datasets!".red.bold
65
+ safe_msg = "Your password was not found in a dataset.".green.bold
66
+ puts dataset_count ? vuln_msg : safe_msg
67
+ end
68
+
69
+ desc 'about', 'Displays version number and information'
70
+ def about
71
+ puts Dicemypass::BANNER.bold.red
72
+ puts 'version: '.bold + Dicemypass::VERSION.green
73
+ puts 'author: '.bold + 'Keelana'.green
74
+ puts 'homepage: '.bold + 'https://github.com/kchar92/dicemypass'.green
75
+ puts 'learn more: '.bold + 'https://codingdose.info'.green
76
+ puts # extra line, somehow I like them.
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,12 @@
1
+ module Dicemypass
2
+ VERSION = "0.2.1"
3
+ BANNER = '''
4
+ ______ ___ _______ _______ __ __ __ __ _______ _______ _______ _______
5
+ | | | | | || || |_| || | | || || _ || || |
6
+ | _ || | | || ___|| || |_| || _ || |_| || _____|| _____|
7
+ | | | || | | || |___ | || || |_| || || |_____ | |_____
8
+ | |_| || | | _|| ___|| ||_ _|| ___|| ||_____ ||_____ |
9
+ | || | | |_ | |___ | ||_|| | | | | | | _ | _____| | _____| |
10
+ |______| |___| |_______||_______||_| |_| |___| |___| |__| |__||_______||_______|
11
+ '''
12
+ end
metadata ADDED
@@ -0,0 +1,171 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dicemypass
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.1
5
+ platform: ruby
6
+ authors:
7
+ - Keelana Char
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-01-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: colorize
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.8'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: clipboard
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.1'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.17'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.17'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: irb
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 1.0.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 1.0.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: minitest
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '5.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '5.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: minitest-reporters
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1.3'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1.3'
125
+ description: Generates a passphrase using EFF's long wordlist.
126
+ email:
127
+ - keelanachar@gmail.com
128
+ executables:
129
+ - dicemypass
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - ".gitignore"
134
+ - ".travis.yml"
135
+ - Gemfile
136
+ - LICENSE.txt
137
+ - README.md
138
+ - Rakefile
139
+ - bin/console
140
+ - bin/setup
141
+ - dicemypass-0.2.0.gem
142
+ - dicemypass.gemspec
143
+ - exe/dicemypass
144
+ - lib/dicemypass.rb
145
+ - lib/dicemypass/assets/eff_long_wordlist.txt
146
+ - lib/dicemypass/cli.rb
147
+ - lib/dicemypass/version.rb
148
+ homepage: https://github.com/kchar92/dicemypass.git
149
+ licenses:
150
+ - MIT
151
+ metadata: {}
152
+ post_install_message:
153
+ rdoc_options: []
154
+ require_paths:
155
+ - lib
156
+ required_ruby_version: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ required_rubygems_version: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ requirements: []
167
+ rubygems_version: 3.0.3
168
+ signing_key:
169
+ specification_version: 4
170
+ summary: Generate a secure password
171
+ test_files: []