mirror of
https://github.com/nishiki/manage-password.git
synced 2025-02-22 10:50:10 +00:00
fix pinentry mode with gpg 1.4
This commit is contained in:
parent
92cb89ad33
commit
d1adfd24c1
1 changed files with 11 additions and 2 deletions
|
@ -337,9 +337,18 @@ module MPW
|
||||||
def decrypt(data)
|
def decrypt(data)
|
||||||
return nil if data.to_s.empty?
|
return nil if data.to_s.empty?
|
||||||
|
|
||||||
crypto = GPGME::Crypto.new(armor: true)
|
password =
|
||||||
|
if /^1\.[0-9.]+$/ =~ GPGME::Engine.info.first.version
|
||||||
|
{ password: @gpg_pass }
|
||||||
|
else
|
||||||
|
{ password: @gpg_pass,
|
||||||
|
pinentry_mode: GPGME::PINENTRY_MODE_LOOPBACK }
|
||||||
|
end
|
||||||
|
|
||||||
crypto.decrypt(data, password: @gpg_pass, pinentry_mode: GPGME::PINENTRY_MODE_LOOPBACK).read.force_encoding('utf-8')
|
crypto = GPGME::Crypto.new(armor: true)
|
||||||
|
crypto
|
||||||
|
.decrypt(data, password)
|
||||||
|
.read.force_encoding('utf-8')
|
||||||
rescue => e
|
rescue => e
|
||||||
raise "#{I18n.t('error.gpg_file.decrypt')}\n#{e}"
|
raise "#{I18n.t('error.gpg_file.decrypt')}\n#{e}"
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue