Module: Password
- Defined in:
- lib/password.rb
Constant Summary collapse
- VERSION =
'1.0.0'- FILENAME =
honestly, “security”, who gives a shit
"#{ENV['HOME']}/.they_stole_my_facebook_login_oh_noez"- SITES =
{}
Instance Method Summary collapse
- #generate(length = 23) ⇒ Object
- #load_passwords ⇒ Object
- #password(site) ⇒ Object
- #save_passwords ⇒ Object
- #set(credentials) ⇒ Object
- #username(site) ⇒ Object
Instance Method Details
#generate(length = 23) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/password.rb', line 26 def generate(length = 23) # how to make this elegant? password = "" possible = %w{0 1 2 3 4 5 6 7 8 9 0 a b c d e f g h i j k l M N O P Q R S T U V W X Y Z ! $ # @ & * . ' =} length.times {password << possible[rand(possible.size)]} password end |
#load_passwords ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/password.rb', line 19 def load_passwords if File.exists?(FILENAME) SITES.merge!(YAML::load(File.open(FILENAME))) else {} end end |
#password(site) ⇒ Object
13 14 15 |
# File 'lib/password.rb', line 13 def password(site) SITES[site][:password] end |
#save_passwords ⇒ Object
16 17 18 |
# File 'lib/password.rb', line 16 def save_passwords File.open(FILENAME, "w") {|file| file.puts SITES.to_yaml} end |
#set(credentials) ⇒ Object
6 7 8 9 |
# File 'lib/password.rb', line 6 def set(credentials) SITES[credentials[:site]] = {:username => credentials[:username], :password => credentials[:password]} end |
#username(site) ⇒ Object
10 11 12 |
# File 'lib/password.rb', line 10 def username(site) SITES[site][:username] end |