Module: Dmp
- Defined in:
- lib/dmp.rb,
lib/dmp/cli.rb,
lib/dmp/version.rb
Overview
Module to manage DMP operations
Defined Under Namespace
Classes: CLI
Constant Summary collapse
- VERSION =
"0.2.2"- BANNER =
''' ____ __ __ ____ | _ \ | \/ | | _ \ | | | | | |\/| | | |_) | | |_| | | | | | | __/ |____/ |_| |_| |_| '''
Class Method Summary collapse
Class Method Details
.check_pwned(passphrase) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/dmp.rb', line 20 def self.check_pwned(passphrase) if passphrase.kind_of?(Array) passphrase = passphrase.join(' ') end hex_pass = Digest::SHA1.hexdigest(passphrase) hex_pass_sample = hex_pass[0...5] hex_pass_rest = hex_pass[5..-1] # request a sample to HIBP to avoid disclosing the full pwd uri = URI("https://api.pwnedpasswords.com/range/#{hex_pass_sample}") req = Net::HTTP.get(uri) clean_list = req.split("\r\n") pass_list = clean_list.map { |hash| hash.split(':') } pass_hash = Hash[*pass_list.flatten!] pass_hash[hex_pass_rest.upcase] end |
.gen_passphrase(pass_length = 7) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/dmp.rb', line 10 def self.gen_passphrase(pass_length = 7) # load eff_wordlist as a list and strip new lines pass_list = File.readlines(@eff_wordlist) pass_list.map(&:strip!) # randomize wordlist and strip it to the desired length random_pass = pass_list.shuffle[0...pass_length] random_pass end |