home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / p / python / pyhtmldoc / b / binascii < prev    next >
Text File  |  1996-11-14  |  4KB  |  69 lines

  1. <TITLE>binascii -- Python library reference</TITLE>
  2. Next: <A HREF="../x/xdrlib" TYPE="Next">xdrlib</A>  
  3. Prev: <A HREF="../u/uu" TYPE="Prev">uu</A>  
  4. Up: <A HREF="../i/internet_and_www" TYPE="Up">Internet and WWW</A>  
  5. Top: <A HREF="../t/top" TYPE="Top">Top</A>  
  6. <H1>10.15. Built-in Module <CODE>binascii</CODE></H1>
  7. The binascii module contains a number of methods to convert between
  8. binary and various ascii-encoded binary representations. Normally, you
  9. will not use these modules directly but use wrapper modules like
  10. <VAR>uu</VAR> or <VAR>hexbin</VAR> in stead, this module solely exists because
  11. bit-manipuation of large amounts of data is slow in python.
  12. <P>
  13. The <CODE>binascii</CODE> module defines the following functions:
  14. <P>
  15. <DL><DT><B>a2b_uu</B> (<VAR>string</VAR>) -- function of module binascii<DD>
  16. Convert a single line of uuencoded data back to binary and return the
  17. binary data. Lines normally contain 45 (binary) bytes, except for the
  18. last line. Line data may be followed by whitespace.
  19. </DL>
  20. <DL><DT><B>b2a_uu</B> (<VAR>data</VAR>) -- function of module binascii<DD>
  21. Convert binary data to a line of ascii characters, the return value is
  22. the converted line, including a newline char. The length of <VAR>data</VAR>
  23. should be at most 45.
  24. </DL>
  25. <DL><DT><B>a2b_base64</B> (<VAR>string</VAR>) -- function of module binascii<DD>
  26. Convert a block of base64 data back to binary and return the
  27. binary data. More than one line may be passed at a time.
  28. </DL>
  29. <DL><DT><B>b2a_base64</B> (<VAR>data</VAR>) -- function of module binascii<DD>
  30. Convert binary data to a line of ascii characters in base64 coding.
  31. The return value is the converted line, including a newline char.
  32. The length of <VAR>data</VAR> should be at most 57 to adhere to the base64
  33. standard.
  34. </DL>
  35. <DL><DT><B>a2b_hqx</B> (<VAR>string</VAR>) -- function of module binascii<DD>
  36. Convert binhex4 formatted ascii data to binary, without doing
  37. rle-decompression. The string should contain a complete number of
  38. binary bytes, or (in case of the last portion of the binhex4 data)
  39. have the remaining bits zero.
  40. </DL>
  41. <DL><DT><B>rledecode_hqx</B> (<VAR>data</VAR>) -- function of module binascii<DD>
  42. Perform RLE-decompression on the data, as per the binhex4
  43. standard. The algorithm uses <CODE>0x90</CODE> after a byte as a repeat
  44. indicator, followed by a count. A count of <CODE>0</CODE> specifies a byte
  45. value of <CODE>0x90</CODE>. The routine returns the decompressed data,
  46. unless data input data ends in an orphaned repeat indicator, in which
  47. case the <VAR>Incomplete</VAR> exception is raised.
  48. </DL>
  49. <DL><DT><B>rlecode_hqx</B> (<VAR>data</VAR>) -- function of module binascii<DD>
  50. Perform binhex4 style RLE-compression on <VAR>data</VAR> and return the
  51. result.
  52. </DL>
  53. <DL><DT><B>b2a_hqx</B> (<VAR>data</VAR>) -- function of module binascii<DD>
  54. Perform hexbin4 binary-to-ascii translation and return the resulting
  55. string. The argument should already be rle-coded, and have a length
  56. divisible by 3 (except possibly the last fragment).
  57. </DL>
  58. <DL><DT><B>crc_hqx</B> (<VAR>data</VAR>, <VAR>crc</VAR>) -- function of module binascii<DD>
  59. Compute the binhex4 crc value of <VAR>data</VAR>, starting with an initial
  60. <VAR>crc</VAR> and returning the result.
  61. </DL>
  62. <DL><DT><B>Error</B> -- exception of module binascii<DD>
  63. Exception raised on errors. These are usually programming errors.
  64. </DL>
  65. <DL><DT><B>Incomplete</B> -- exception of module binascii<DD>
  66. Exception raised on incomplete data. These are usually not programming
  67. errors, but handled by reading a little more data and trying again.
  68. </DL>
  69.