I have GPG set up on my windows box and my linux box. I have the same keypairs on both. I can encrypt & decrypt on both systems fine when using the command line but i now want to automate things with pyme. Unfortunately, I have hit a problem which I cant get past. The scripts I have can enumerate keys and encrypt files & text easily, but whenever I decrypt it freezes dead. Here's an example
As I said, it freezes on both linux & windows, but on linux it brings up a dialog to get my passpharse. if I click cancel the script continues and decrypts the data as it should.Code:from pyme import core, constants def Callback(x, y, z): """ Callback to give password """ return "MyPasswordHere\n" plaintext = "Hello World!" crypttext = "" #First set of data plaindata1 = core.Data(plaintext) cryptdata1 = core.Data() cont = core.Context() cont.set_armor(True) #ASCII cont.op_keylist_start("MyKeyNameHere", 1) #use first key cont.op_encrypt([cont.op_keylist_next()], 1, plaindata1, cryptdata1) cryptdata1.seek(0,0) crypttext = cryptdata1.read() print "Encrypted Data:\n %s" % crypttext cryptdata2 = core.Data(crypttext) plaindata2 = core.Data() cont.set_passphrase_cb(Callback) cont.op_decrypt(cryptdata2, plaindata2) #freeze here!!!! plaindata2.seek(0,0) print "Decrypted Data:\n %s" % crypttext
I've scoured the web and newsgroups and looked through the pyme & gpgme docs, but I cant figure it out! I cant understand why it's freezing. Any ideas?


Reply With Quote
Bookmarks