Module: Mmfa

Defined in:
lib/mmfa.rb,
lib/mmfa/version.rb

Constant Summary collapse

VERSION =
"1.0.0"

Class Method Summary collapse

Class Method Details

.current_key(keychain_item_name) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/mmfa.rb', line 6

def self.current_key(keychain_item_name)
  secret = `security find-generic-password -ga #{keychain_item_name} 2>&1 | perl -e 'if (<STDIN> =~ m/password: "(.*)"$/ ) { print $1; }'`
  ga = GoogleAuthenticator.new(secret)
  current_key = ga.get_keys[1]
  `printf '#{current_key}' | pbcopy`
  puts current_key
end