1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/tests/test_sign.py Sat Jul 21 23:52:59 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 import message_from_string
1.10 +import sys
1.11 +
1.12 +if __name__ == "__main__":
1.13 + message = sys.argv[1]
1.14 + text = open(message).read()
1.15 + signature = sys.stdin.read()
1.16 + protocol = "application/pgp-signature"
1.17 + subtype = "signed"
1.18 +
1.19 + # Make the container for the message.
1.20 +
1.21 + message = MIMEMultipart(subtype, protocol=protocol)
1.22 +
1.23 + submessage = message_from_string(text)
1.24 + message.attach(submessage)
1.25 +
1.26 + signature_part = MIMEBase("application", "pgp-signature")
1.27 + signature_part.set_payload(signature)
1.28 + message.attach(signature_part)
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