pyme

Problem decrypting PGP in python with pyme without user interaction

倖福魔咒の 提交于 2019-12-12 09:27:21
问题 I am trying to decrypt messages using pyme (a python wrapper from gpgme). It works fine if I type in the password when it prompts but I cannot get the passphrase callback to work. Here is the code import pyme.core def Callback( x, y, z ): print 'in passphrase callback' return 'passphrase' plain = pyme.core.Data() cipher = pyme.core.Data(sys.stdin.read()) c = pyme.core.Context() c.set_armor(1) c.set_passphrase_cb(Callback) c.op_decrypt( cipher, plain ) plain.seek(0,0) print plain.read() When I

Problem decrypting PGP in python with pyme without user interaction

爱⌒轻易说出口 提交于 2019-12-04 20:45:00
I am trying to decrypt messages using pyme (a python wrapper from gpgme). It works fine if I type in the password when it prompts but I cannot get the passphrase callback to work. Here is the code import pyme.core def Callback( x, y, z ): print 'in passphrase callback' return 'passphrase' plain = pyme.core.Data() cipher = pyme.core.Data(sys.stdin.read()) c = pyme.core.Context() c.set_armor(1) c.set_passphrase_cb(Callback) c.op_decrypt( cipher, plain ) plain.seek(0,0) print plain.read() When I run this and don't provide the password interactively the program then tries the Callback printing 'in