Created
May 26, 2013 22:29
-
-
Save sfstpala/5654253 to your computer and use it in GitHub Desktop.
GPG Signatue with python3-gpgme
This file contains 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
#!/usr/bin/python3 | |
import io | |
import gpgme | |
def sign(filename): | |
context = gpgme.Context() | |
context.armor = True | |
context.signers = tuple(i for i in context.keylist() if i.can_sign) | |
signature = io.BytesIO() | |
with open(filename, "rb") as f: | |
context.sign(f, signature, gpgme.SIG_MODE_DETACH) | |
return signature.getvalue().decode('ascii') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment