home *** CD-ROM | disk | FTP | other *** search
- <TITLE>binascii -- Python library reference</TITLE>
- Next: <A HREF="../x/xdrlib" TYPE="Next">xdrlib</A>
- Prev: <A HREF="../u/uu" TYPE="Prev">uu</A>
- Up: <A HREF="../i/internet_and_www" TYPE="Up">Internet and WWW</A>
- Top: <A HREF="../t/top" TYPE="Top">Top</A>
- <H1>10.15. Built-in Module <CODE>binascii</CODE></H1>
- The binascii module contains a number of methods to convert between
- binary and various ascii-encoded binary representations. Normally, you
- will not use these modules directly but use wrapper modules like
- <VAR>uu</VAR> or <VAR>hexbin</VAR> in stead, this module solely exists because
- bit-manipuation of large amounts of data is slow in python.
- <P>
- The <CODE>binascii</CODE> module defines the following functions:
- <P>
- <DL><DT><B>a2b_uu</B> (<VAR>string</VAR>) -- function of module binascii<DD>
- Convert a single line of uuencoded data back to binary and return the
- binary data. Lines normally contain 45 (binary) bytes, except for the
- last line. Line data may be followed by whitespace.
- </DL>
- <DL><DT><B>b2a_uu</B> (<VAR>data</VAR>) -- function of module binascii<DD>
- Convert binary data to a line of ascii characters, the return value is
- the converted line, including a newline char. The length of <VAR>data</VAR>
- should be at most 45.
- </DL>
- <DL><DT><B>a2b_base64</B> (<VAR>string</VAR>) -- function of module binascii<DD>
- Convert a block of base64 data back to binary and return the
- binary data. More than one line may be passed at a time.
- </DL>
- <DL><DT><B>b2a_base64</B> (<VAR>data</VAR>) -- function of module binascii<DD>
- Convert binary data to a line of ascii characters in base64 coding.
- The return value is the converted line, including a newline char.
- The length of <VAR>data</VAR> should be at most 57 to adhere to the base64
- standard.
- </DL>
- <DL><DT><B>a2b_hqx</B> (<VAR>string</VAR>) -- function of module binascii<DD>
- Convert binhex4 formatted ascii data to binary, without doing
- rle-decompression. The string should contain a complete number of
- binary bytes, or (in case of the last portion of the binhex4 data)
- have the remaining bits zero.
- </DL>
- <DL><DT><B>rledecode_hqx</B> (<VAR>data</VAR>) -- function of module binascii<DD>
- Perform RLE-decompression on the data, as per the binhex4
- standard. The algorithm uses <CODE>0x90</CODE> after a byte as a repeat
- indicator, followed by a count. A count of <CODE>0</CODE> specifies a byte
- value of <CODE>0x90</CODE>. The routine returns the decompressed data,
- unless data input data ends in an orphaned repeat indicator, in which
- case the <VAR>Incomplete</VAR> exception is raised.
- </DL>
- <DL><DT><B>rlecode_hqx</B> (<VAR>data</VAR>) -- function of module binascii<DD>
- Perform binhex4 style RLE-compression on <VAR>data</VAR> and return the
- result.
- </DL>
- <DL><DT><B>b2a_hqx</B> (<VAR>data</VAR>) -- function of module binascii<DD>
- Perform hexbin4 binary-to-ascii translation and return the resulting
- string. The argument should already be rle-coded, and have a length
- divisible by 3 (except possibly the last fragment).
- </DL>
- <DL><DT><B>crc_hqx</B> (<VAR>data</VAR>, <VAR>crc</VAR>) -- function of module binascii<DD>
- Compute the binhex4 crc value of <VAR>data</VAR>, starting with an initial
- <VAR>crc</VAR> and returning the result.
- </DL>
- <DL><DT><B>Error</B> -- exception of module binascii<DD>
- Exception raised on errors. These are usually programming errors.
- </DL>
- <DL><DT><B>Incomplete</B> -- exception of module binascii<DD>
- Exception raised on incomplete data. These are usually not programming
- errors, but handled by reading a little more data and trying again.
- </DL>
-