From: Andrew Engelbrecht Date: Sat, 18 Jul 2015 21:28:08 +0000 (-0400) Subject: created a function for choosing the encryption key X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=fafa21c3630f2361348635d6a70a801f0c7e4e31;p=edward.git created a function for choosing the encryption key this is somewhat more intelligent and can be improved upon later. --- diff --git a/edward-bot b/edward-bot index 76c3758..ce55408 100755 --- a/edward-bot +++ b/edward-bot @@ -45,12 +45,13 @@ def main (): plaintext, keys = email_decode_flatten (email_text) email_from, email_subject = email_from_subject(email_text) + reply_encrypt_to_key = choose_reply_encryption_key(keys) + print("From: " + email_from) print("Subject: " + email_subject) print(plaintext) - for key in keys: - print(key.subkeys[0].fpr) + print(reply_encrypt_to_key.subkeys[0].fpr) def email_decode_flatten (email_text): @@ -206,6 +207,17 @@ def decrypt_chunk (gpg_chunk): return (plaintext, sigs) +def choose_reply_encryption_key (keys): + + reply_key = None + for key in keys: + if (key.can_encrypt == True): + reply_key = key + break + + return key + + def handle_args (): if __name__ == "__main__":