diff --git a/gpgmymail b/gpgmymail index 1125fe0..721cc6a 100755 --- a/gpgmymail +++ b/gpgmymail @@ -38,6 +38,9 @@ import typing # see: https://gnupg.readthedocs.io/en/latest/ import gnupg +# constants +ENCODING='utf-8' # default is latin-1 which fails w some unicode chars + def is_message_encrypted(message: email.message.Message) -> bool: """Determines whether or not an email message is encrypted. @@ -69,7 +72,7 @@ def encrypt( return message.as_string() gpg = gnupg.GPG() - # gpg.encoding = 'utf-8' # default is latin-1 which fails w some unicode chars + gpg.encoding = ENCODING encrypted_content = gpg.encrypt(message.as_string(), recipients, armor=True) if not encrypted_content: raise ValueError(encrypted_content.status) @@ -108,7 +111,9 @@ def encrypt( def decrypt(message: email.message.Message) -> str: """Decrypt the given message Likely won't work on this server as I don't store private keys""" - return str(gnupg.GPG().decrypt(message.as_string())) + gpg = gnupg.GPG() + gpg.encoding = ENCODING + return str(gpg.decrypt(message.as_string())) def main() -> None: """Program entry"""