Created
February 1, 2018 23:37
-
-
Save krescruz/e3c2b52f5729dfb2e51143457eeefa2c to your computer and use it in GitHub Desktop.
Encrypting files using GNU Privacy Guard (GnuPG or GPG) - Command line example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import gnupg | |
def main(): | |
path_home = sys.argv[1] | |
path_file_input = sys.argv[2] | |
path_file_output = sys.argv[3] | |
gpg = gnupg.GPG(gnupghome=path_home) | |
key = gpg.list_keys() | |
with open(path_file_input, 'rb') as file: | |
encrypted = gpg.encrypt_file(file, recipients=key.uids, | |
always_trust=True, output=path_file_output) | |
if not encrypted.ok: | |
raise encrypted.stderr | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Command line example