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)
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 = "***"
'''
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