password_genie 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/password_genie.rb +130 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cb68e0e986cb9bfa681ae90cbc55e3d71fa4152a
|
4
|
+
data.tar.gz: f066c7385d2483054da1f1e584350b16bbfea610
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8c0c5e39bb18c007f81de88cbb6813036600edbdd9b6596bbec538886cb25575c0463c950a470d8b7305ecb61935e9e72e33c67ce69000945c727be9aacb993e
|
7
|
+
data.tar.gz: b0cb658890474c67ce474152f6320f607d048bb198d10b063a182728fd628f53d449ae7c16286483d1f39b99a8dfe2feb33c7310451c090d63879c3a308e2a51
|
@@ -0,0 +1,130 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#password_genie.rb
|
3
|
+
|
4
|
+
class WordBank
|
5
|
+
attr_reader :word_bank, :number, :special_chars
|
6
|
+
|
7
|
+
def word_bank=(words)
|
8
|
+
word_bank=words.split("").to_a
|
9
|
+
word_bank.delete(" ")
|
10
|
+
unless word_bank.is_a?(Array)
|
11
|
+
raise "word bank must contain letters"
|
12
|
+
end
|
13
|
+
@word_bank= word_bank
|
14
|
+
end
|
15
|
+
|
16
|
+
def number=(number)
|
17
|
+
unless number.is_a?(Fixnum)
|
18
|
+
raise "whole numbers only, please"
|
19
|
+
end
|
20
|
+
if number<=0
|
21
|
+
raise ">= 0 only, please"
|
22
|
+
end
|
23
|
+
@number=number
|
24
|
+
end
|
25
|
+
|
26
|
+
def special_chars=(special_chars)
|
27
|
+
@special_chars=[".",",","$","?","!"]
|
28
|
+
end
|
29
|
+
|
30
|
+
def initialize(words,number=8)
|
31
|
+
self.word_bank = words
|
32
|
+
self.number = number
|
33
|
+
self.special_chars = special_chars
|
34
|
+
@password_ary = []
|
35
|
+
@numbers= (0..9).to_a
|
36
|
+
end
|
37
|
+
|
38
|
+
def add_special_chars
|
39
|
+
word_bank.concat(@special_chars)
|
40
|
+
puts "word bak with special chars: #{word_bank}"
|
41
|
+
@word_bank
|
42
|
+
end
|
43
|
+
|
44
|
+
def add_numbers
|
45
|
+
word_bank.concat(@numbers)
|
46
|
+
puts "word bank with numbers: #{word_bank}"
|
47
|
+
@word_bank
|
48
|
+
end
|
49
|
+
|
50
|
+
def create
|
51
|
+
puts "word bank: #{word_bank}"
|
52
|
+
i = number
|
53
|
+
while i != 0
|
54
|
+
if i == 2 && word_bank.include?(@special_chars) && @password_ary.include?(@special_chars) == false
|
55
|
+
@password_ary << @special_chars[rand(1..@special_chars.size)]
|
56
|
+
end
|
57
|
+
if i == 1 && word_bank.include?(@numbers) && password_ary.include?(@numbers) == false
|
58
|
+
@password_ary << @numbers[rand(1..@numbers.size)]
|
59
|
+
end
|
60
|
+
letter = rand(1..word_bank.size-1)
|
61
|
+
puts word_bank.size
|
62
|
+
puts "letter: #{letter}"
|
63
|
+
@password_ary << word_bank[letter]
|
64
|
+
puts "letter : #{word_bank[letter]}"
|
65
|
+
word_bank.delete_at(letter)
|
66
|
+
puts "i #{i}"
|
67
|
+
puts "else"
|
68
|
+
i -= 1
|
69
|
+
end
|
70
|
+
@password = @password_ary.join()
|
71
|
+
puts @password
|
72
|
+
@password
|
73
|
+
end
|
74
|
+
|
75
|
+
def save_info(site,username)
|
76
|
+
myfile=File.open('site_info.txt','a+') do |data_file|
|
77
|
+
puts "#{site} | [username: #{username}] password: #{@password}"
|
78
|
+
data_file.write("#{site} | [username: #{username}] password: #{@password}\n")
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
go = true
|
84
|
+
|
85
|
+
while go
|
86
|
+
puts "HELLO. You will now design you custom password!"
|
87
|
+
puts "How long do you want your password to be?"
|
88
|
+
|
89
|
+
number = gets.chomp.to_i
|
90
|
+
if number == 1
|
91
|
+
word_number = "character"
|
92
|
+
else
|
93
|
+
word_number = "characters"
|
94
|
+
end
|
95
|
+
puts "your word bank will contain #{number} #{word_number} long."
|
96
|
+
|
97
|
+
|
98
|
+
puts "please compile your word bank:"
|
99
|
+
words = gets.chomp
|
100
|
+
|
101
|
+
#word_bank= words.split("")
|
102
|
+
#word_bank.delete(' ')
|
103
|
+
x = WordBank.new(words, number)
|
104
|
+
|
105
|
+
puts 'do you wish to include special characters such as "." "," and "$"? [y/n]'
|
106
|
+
special_char = gets.chomp
|
107
|
+
x.add_special_chars unless special_char == "n"
|
108
|
+
puts "do you wish to include numbers? [y/n]"
|
109
|
+
num_chc = gets.chomp
|
110
|
+
x.add_numbers unless num_chc == 'n'
|
111
|
+
x.create
|
112
|
+
|
113
|
+
puts "done.\n\n"
|
114
|
+
puts "\tto save, please enter 'save'"
|
115
|
+
choice = gets.chomp.downcase
|
116
|
+
if choice == 'save' || choice == 's' || choice == 'yes' || choice == 'y'
|
117
|
+
puts "enter site"
|
118
|
+
site = gets.chomp.downcase
|
119
|
+
puts "enter username"
|
120
|
+
username = gets.chomp.to_s
|
121
|
+
x.save_info(site,username)
|
122
|
+
end
|
123
|
+
|
124
|
+
puts "go again? [y/n]"
|
125
|
+
choice = gets.chomp
|
126
|
+
unless choice == 'y'
|
127
|
+
go = false
|
128
|
+
end
|
129
|
+
next
|
130
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: password_genie
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- fookh
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-06-01 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: a simple tool to 1. build a password based on user defined parameters
|
14
|
+
and 2. archive passwords, usernames, and corresponding site data
|
15
|
+
email: foo@yetispeak.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/password_genie.rb
|
21
|
+
homepage: http://rubygems.org/gems/password_genie
|
22
|
+
licenses:
|
23
|
+
- MIT
|
24
|
+
metadata: {}
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project:
|
41
|
+
rubygems_version: 2.5.2.1
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: password_genie
|
45
|
+
test_files: []
|