home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / p / python / !ibrowse / files / pylibi-8 (.txt) < prev    next >
GNU Info File  |  1996-11-14  |  36KB  |  697 lines

  1. This is Info file pylibi, produced by Makeinfo-1.55 from the input file
  2. lib.texi.
  3. This file describes the built-in types, exceptions and functions and the
  4. standard modules that come with the Python system.  It assumes basic
  5. knowledge about the Python language.  For an informal introduction to
  6. the language, see the Python Tutorial.  The Python Reference Manual
  7. gives a more formal definition of the language.  (These manuals are not
  8. yet available in INFO or Texinfo format.)
  9. Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, The
  10. Netherlands.
  11. All Rights Reserved
  12. Permission to use, copy, modify, and distribute this software and its
  13. documentation for any purpose and without fee is hereby granted,
  14. provided that the above copyright notice appear in all copies and that
  15. both that copyright notice and this permission notice appear in
  16. supporting documentation, and that the names of Stichting Mathematisch
  17. Centrum or CWI or Corporation for National Research Initiatives or CNRI
  18. not be used in advertising or publicity pertaining to distribution of
  19. the software without specific, written prior permission.
  20. While CWI is the initial source for this software, a modified version
  21. is made available by the Corporation for National Research Initiatives
  22. (CNRI) at the Internet address ftp://ftp.python.org.
  23. STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
  24. REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
  25. MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
  26. CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
  27. DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  28. PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
  29. ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
  30. THIS SOFTWARE.
  31. File: pylibi,  Node: Bastion,  Prev: rexec,  Up: Restricted Execution
  32. Standard Module `Bastion'
  33. =========================
  34. According to the dictionary, a bastion is "a fortified area or
  35. position", or "something that is considered a stronghold."  It's a
  36. suitable name for this module, which provides a way to forbid access to
  37. certain attributes of an object.  It must always be used with the
  38. `rexec' module, in order to allow restricted-mode programs access to
  39. certain safe attributes of an object, while denying access to other,
  40. unsafe attributes.
  41.  - function of module Bastion: Bastion (OBJECT[, FILTER, NAME, CLASS])
  42.      Protect the class instance OBJECT, returning a bastion for the
  43.      object.  Any attempt to access one of the object's attributes will
  44.      have to be approved by the FILTER function; if the access is
  45.      denied an AttributeError exception will be raised.
  46.      If present, FILTER must be a function that accepts a string
  47.      containing an attribute name, and returns true if access to that
  48.      attribute will be permitted; if FILTER returns false, the access
  49.      is denied.  The default filter denies access to any function
  50.      beginning with an underscore (`_').  The bastion's string
  51.      representation will be `<Bastion for NAME>' if a value for NAME is
  52.      provided; otherwise, `repr(OBJECT)' will be used.
  53.      CLASS, if present, would be a subclass of `BastionClass'; see the
  54.      code in `bastion.py' for the details.  Overriding the default
  55.      `BastionClass' will rarely be required.
  56. File: pylibi,  Node: Cryptographic Services,  Next: RISCOS ONLY,  Prev: Restricted Execution,  Up: Top
  57. Cryptographic Services
  58. **********************
  59. The modules described in this chapter implement various algorithms of a
  60. cryptographic nature.  They are available at the discretion of the
  61. installation.  Here's an overview:
  62.      -- RSA's MD5 message digest algorithm.
  63.      -- Interface to the GNU MP library for arbitrary precision
  64.      arithmetic.
  65. rotor
  66.      -- Enigma-like encryption and decryption.
  67. Hardcore cypherpunks will probably find the cryptographic modules
  68. written by Andrew Kuchling of further interest; the package adds
  69. built-in modules for DES and IDEA encryption, provides a Python module
  70. for reading and decrypting PGP files, and then some.  These modules are
  71. not distributed with Python but available separately.  See the URL
  72. `http://www.magnet.com/~amk/python/pct.html' or send email to
  73. `amk@magnet.com' for more information.
  74. * Menu:
  75. * md5::
  76. * mpz::
  77. * rotor::
  78. File: pylibi,  Node: md5,  Next: mpz,  Prev: Cryptographic Services,  Up: Cryptographic Services
  79. Built-in Module `md5'
  80. =====================
  81. This module implements the interface to RSA's MD5 message digest
  82. algorithm (see also Internet RFC 1321).  Its use is quite
  83. straightforward: use the `md5.new()' to create an md5 object.  You can
  84. now feed this object with arbitrary strings using the `update()'
  85. method, and at any point you can ask it for the "digest" (a strong kind
  86. of 128-bit checksum, a.k.a. "fingerprint") of the contatenation of the
  87. strings fed to it so far using the `digest()' method.
  88. For example, to obtain the digest of the string "Nobody inspects the
  89. spammish repetition":
  90.      >>> import md5
  91.      >>> m = md5.new()
  92.      >>> m.update("Nobody inspects")
  93.      >>> m.update(" the spammish repetition")
  94.      >>> m.digest()
  95.      '\273d\234\203\335\036\245\311\331\336\311\241\215\360\377\351'
  96. More condensed:
  97.      >>> md5.new("Nobody inspects the spammish repetition").digest()
  98.      '\273d\234\203\335\036\245\311\331\336\311\241\215\360\377\351'
  99.  - function of module md5: new ([ARG])
  100.      Return a new md5 object.  If ARG is present, the method call
  101.      `update(ARG)' is made.
  102.  - function of module md5: md5 ([ARG])
  103.      For backward compatibility reasons, this is an alternative name
  104.      for the `new()' function.
  105. An md5 object has the following methods:
  106.  - Method on md5: update (ARG)
  107.      Update the md5 object with the string ARG.  Repeated calls are
  108.      equivalent to a single call with the concatenation of all the
  109.      arguments, i.e. `m.update(a); m.update(b)' is equivalent to
  110.      `m.update(a+b)'.
  111.  - Method on md5: digest ()
  112.      Return the digest of the strings passed to the `update()' method
  113.      so far.  This is an 16-byte string which may contain non-ASCII
  114.      characters, including null bytes.
  115.  - Method on md5: copy ()
  116.      Return a copy ("clone") of the md5 object.  This can be used to
  117.      efficiently compute the digests of strings that share a common
  118.      initial substring.
  119. File: pylibi,  Node: mpz,  Next: rotor,  Prev: md5,  Up: Cryptographic Services
  120. Built-in Module `mpz'
  121. =====================
  122. This is an optional module.  It is only available when Python is
  123. configured to include it, which requires that the GNU MP software is
  124. installed.
  125. This module implements the interface to part of the GNU MP library,
  126. which defines arbitrary precision integer and rational number
  127. arithmetic routines.  Only the interfaces to the *integer* (`mpz_...')
  128. routines are provided. If not stated otherwise, the description in the
  129. GNU MP documentation can be applied.
  130. In general, "mpz"-numbers can be used just like other standard Python
  131. numbers, e.g. you can use the built-in operators like `+', `*', etc.,
  132. as well as the standard built-in functions like `abs', `int', ...,
  133. `divmod', `pow'.  *Please note:* the bitwise-xor operation has been
  134. implemented as a bunch of ands, inverts and ors, because the library
  135. lacks an `mpz_xor' function, and I didn't need one.
  136. You create an mpz-number by calling the function called `mpz' (see
  137. below for an exact description). An mpz-number is printed like this:
  138. `mpz(VALUE)'.
  139.  - function of module mpz: mpz (VALUE)
  140.      Create a new mpz-number. VALUE can be an integer, a long, another
  141.      mpz-number, or even a string. If it is a string, it is interpreted
  142.      as an array of radix-256 digits, least significant digit first,
  143.      resulting in a positive number. See also the `binary' method,
  144.      described below.
  145. A number of *extra* functions are defined in this module. Non
  146. mpz-arguments are converted to mpz-values first, and the functions
  147. return mpz-numbers.
  148.  - function of module mpz: powm (BASE, EXPONENT, MODULUS)
  149.      Return `pow(BASE, EXPONENT) % MODULUS'. If `EXPONENT == 0', return
  150.      `mpz(1)'. In contrast to the C-library function, this version can
  151.      handle negative exponents.
  152.  - function of modul