0

Thanks in advance!

I am new to Python.

I want to PGP encrypt a file named "input.csv" using a downloaded "pgp_keys.asc" file.

Here is my attempt:

def encrypt(key, src):

    import requests
    r = requests.get(key)

    with open("/home/zzz/.gnupg/pgp_keys.asc",'wb') as f:
        f.write(r.content)
        f.close()

    import gnupg
    gpg=gnupg.GPG(homedir='/home/zzz/.gnupg/')
    f = open(src,'rb')
    status = gpg.encrypt(f)

    print(status.ok)
    print(status.status)
    print(status.stderr)

But code fails with

False None gpg: Sorry, no terminal at all requested - can't get input

My use case is given an input file and public key, encrypt that file.

user1393608
  • 1,299
  • 3
  • 16
  • 29

0 Answers0