gnupg_encrypt.py 521 B

1234567891011121314151617
  1. import gnupg
  2. from pathlib import Path
  3. def encrypt(source_file):
  4. config_dir = Path().cwd() / "config/gnupg"
  5. gpg = gnupg.GPG(homedir=config_dir)
  6. # gpg.import_keys(base_dir + 'export.gpg')
  7. # public_keys = gpg.list_keys()
  8. # print(public_keys)
  9. with open(source_file, "rb") as frh:
  10. result = gpg.encrypt(frh, "942170BF95EA785E8D4A5C94D1839587F0E1C01C", output=str(source_file) + ".gpg")
  11. # 'BV_IFC; BMW Group <BV_IFC@softlab.de>'
  12. print(result.stderr)
  13. # , verbose=True