1 #!/usr/bin/env python 2 3 from email.mime.multipart import MIMEMultipart 4 from email.mime.application import MIMEApplication 5 from email.mime.base import MIMEBase 6 from email.encoders import encode_noop 7 import sys 8 9 if __name__ == "__main__": 10 text = sys.stdin.read() 11 protocol = "application/pgp-encrypted" 12 subtype = "encrypted" 13 14 # Make the container for the message. 15 16 message = MIMEMultipart(subtype, protocol=protocol) 17 18 # For encrypted content, add the declaration and content. 19 20 declaration = MIMEBase("application", "pgp-encrypted") 21 declaration.set_payload("Version: 1") 22 message.attach(declaration) 23 24 content = MIMEApplication(text, "octet-stream", encode_noop) 25 message.attach(content) 26 27 # Show the resulting message text. 28 29 text = message.as_string() 30 31 print text 32 33 # vim: tabstop=4 expandtab shiftwidth=4