Class: DynamoSecret::Gpg
- Inherits:
-
Object
- Object
- DynamoSecret::Gpg
- Defined in:
- lib/dynamo_secret/gpg.rb
Instance Method Summary collapse
Instance Method Details
#decrypt(data) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/dynamo_secret/gpg.rb', line 3 def decrypt(data) crypto.decrypt(data).read rescue GPGME::Error::NoData $stderr.puts 'Key was found but GPG decrypt failed - skipping' data end |
#encrypt(data) ⇒ Object
10 11 12 |
# File 'lib/dynamo_secret/gpg.rb', line 10 def encrypt(data) crypto.encrypt(data, recipients: [key.uids.first.name]).read end |
#key ⇒ Object
14 15 16 |
# File 'lib/dynamo_secret/gpg.rb', line 14 def key @gpg_key ||= GPGME::Key.find(:secret).map { |k| k if k.expires > Date.today.to_time }.first end |