Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to encrypt files in batch #237

Open
yunweiguo opened this issue Jul 25, 2018 · 0 comments
Open

How to encrypt files in batch #237

yunweiguo opened this issue Jul 25, 2018 · 0 comments

Comments

@yunweiguo
Copy link

yunweiguo commented Jul 25, 2018

I want to encrypt two and more files in one times.
the function is

'''

def encrypt_file
gpg = gnupg.GPG(homedir=config.GNUPGHOME, binary='/usr/bin/gpg')
with open(source_file) as f:
data = f.read()
fg = "***"

out = gpg.encrypt(data, fg, default_key=True,
                  passphrase=config.TIGER_GPG_PASS_PHRASE, armor=False, output=target_file)
with open(target_file, 'wb') as f:
    f.write(out.data)

'''

and below is how i encrypt them

`
a = 'a.xml'
a_gpg = "{}.gpg".format(a)
encrypt_file(a, a_gpg)

b = 'b.xml'
b_gpg = "{}.gpg".format(b)
encrypt_file(b, b_gpg)
`

However the output files something looks bad, they garbled.. maybe a file garbled, maybe b file garbled. or no one , or both of them garbled... It seems the problem occur randomly.

But If I just only encrypt one file like
`
a = 'a.xml'
a_gpg = "{}.gpg".format(a)
encrypt_file(a, a_gpg)

`

nothing goes wrong...

So is there someone can tell me how can I fix it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant