1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/tests/test_encrypt_wrap.py Sat Oct 20 18:21:20 2012 +0200
1.3 @@ -0,0 +1,33 @@
1.4 +#!/usr/bin/env python
1.5 +
1.6 +from email.mime.multipart import MIMEMultipart
1.7 +from email.mime.application import MIMEApplication
1.8 +from email.mime.base import MIMEBase
1.9 +from email.encoders import encode_noop
1.10 +import sys
1.11 +
1.12 +if __name__ == "__main__":
1.13 + text = sys.stdin.read()
1.14 + protocol = "application/pgp-encrypted"
1.15 + subtype = "encrypted"
1.16 +
1.17 + # Make the container for the message.
1.18 +
1.19 + message = MIMEMultipart(subtype, protocol=protocol)
1.20 +
1.21 + # For encrypted content, add the declaration and content.
1.22 +
1.23 + declaration = MIMEBase("application", "pgp-encrypted")
1.24 + declaration.set_payload("Version: 1")
1.25 + message.attach(declaration)
1.26 +
1.27 + content = MIMEApplication(text, "octet-stream", encode_noop)
1.28 + message.attach(content)
1.29 +
1.30 + # Show the resulting message text.
1.31 +
1.32 + text = message.as_string()
1.33 +
1.34 + print text
1.35 +
1.36 +# vim: tabstop=4 expandtab shiftwidth=4