File: exporting.rst

package info (click to toggle)
python-pgpy 0.6.0-1.4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,212 kB
  • sloc: python: 8,448; makefile: 155; sh: 10
file content (23 lines) | stat: -rw-r--r-- 594 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Exporting PGP* Objects
======================

PGPKey, PGPMessage, and PGPSignature objects can all be exported to OpenPGP-compatible binary and ASCII-armored formats.

To export in ASCII-armored format::

    # This works in both Python 2.x and 3.x
    # ASCII-armored format
    # cleartext PGPMessages will also have properly canonicalized and dash-escaped
    # message text
    pgpstr = str(pgpobj)

To export to binary format in Python 3::

    # binary format
    pgpbytes = bytes(pgpobj)

To export to binary format in Python 2::

    # binary format
    pgpbytes = pgpobj.__bytes__()