Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(5)  |  Call(3)  |  Derive(0)  |  Import(2)
Given a string (s), string holding a message type (type), and a
list of key-value pairs for headers, generates an OpenPGP-style
ASCII-armored message of type 'type', with contents 's' and
headers 'header'.

If base64 is false, uses cleartext armor.

        def armorText(s, type, headers=(), base64=1):
    """Given a string (s), string holding a message type (type), and a
       list of key-value pairs for headers, generates an OpenPGP-style
       ASCII-armored message of type 'type', with contents 's' and
       headers 'header'.

       If base64 is false, uses cleartext armor."""
    result = []
    result.append("-----BEGIN %s-----\n" %type)
    for k,v in headers:
        result.append("%s: %s\n" %(k,v))
    result.append("\n")
    if base64:
        result.append(encodeBase64(s, lineWidth=64))
    else:
        result.append(DASH_ARMOR_RE.sub('- -', s))
    if not result[-1].endswith("\n"):
        result.append("\n")
    result.append("-----END %s-----\n" %type)

    return "".join(result)
        


src/m/i/mixminion-HEAD/lib/mixminion/Packet.py   mixminion(Download)
import zlib
from socket import inet_ntoa, inet_aton
from mixminion.Common import MixError, MixFatalError, encodeBase64, \
     floorDiv, formatBase64, formatTime, isSMTPMailbox, LOG, armorText, \
     unarmorText, isPlausibleHostname
    def packAsText(self):
        """Returns the external text representation of this reply block"""
        return armorText(self.pack(), RB_ARMOR_NAME,
                         headers=(("Version", "0.2"),))
 
                           binascii.b2a_base64(self.tag).strip()))
 
        return armorText(c, MESSAGE_ARMOR_NAME, headers=fields,
                         base64=(self.messageType!='TXT'))
 

src/m/i/mixminion-HEAD/lib/mixminion/ClientUtils.py   mixminion(Download)
import mixminion.Packet
 
from mixminion.Common import LOG, MixError, UIError, ceilDiv, \
     createPrivateDir, floorDiv, previousMidnight, readFile, \
     succeedingMidnight, writeFile, armorText, unarmorText, MixFatalError
    encrypted = ctr_crypt(data+digest, key)
    contents = "".join([magic,"\x00",salt,encrypted])
    writeFile(fname, armorText(contents,
                               "TYPE III KEYRING", [("Version","0.1")]))