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 >
Wrap
GNU Info File
|
1996-11-14
|
36KB
|
697 lines
This is Info file pylibi, produced by Makeinfo-1.55 from the input file
lib.texi.
This file describes the built-in types, exceptions and functions and the
standard modules that come with the Python system. It assumes basic
knowledge about the Python language. For an informal introduction to
the language, see the Python Tutorial. The Python Reference Manual
gives a more formal definition of the language. (These manuals are not
yet available in INFO or Texinfo format.)
Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, The
Netherlands.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Stichting Mathematisch
Centrum or CWI or Corporation for National Research Initiatives or CNRI
not be used in advertising or publicity pertaining to distribution of
the software without specific, written prior permission.
While CWI is the initial source for this software, a modified version
is made available by the Corporation for National Research Initiatives
(CNRI) at the Internet address ftp://ftp.python.org.
STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
File: pylibi, Node: Bastion, Prev: rexec, Up: Restricted Execution
Standard Module `Bastion'
=========================
According to the dictionary, a bastion is "a fortified area or
position", or "something that is considered a stronghold." It's a
suitable name for this module, which provides a way to forbid access to
certain attributes of an object. It must always be used with the
`rexec' module, in order to allow restricted-mode programs access to
certain safe attributes of an object, while denying access to other,
unsafe attributes.
- function of module Bastion: Bastion (OBJECT[, FILTER, NAME, CLASS])
Protect the class instance OBJECT, returning a bastion for the
object. Any attempt to access one of the object's attributes will
have to be approved by the FILTER function; if the access is
denied an AttributeError exception will be raised.
If present, FILTER must be a function that accepts a string
containing an attribute name, and returns true if access to that
attribute will be permitted; if FILTER returns false, the access
is denied. The default filter denies access to any function
beginning with an underscore (`_'). The bastion's string
representation will be `<Bastion for NAME>' if a value for NAME is
provided; otherwise, `repr(OBJECT)' will be used.
CLASS, if present, would be a subclass of `BastionClass'; see the
code in `bastion.py' for the details. Overriding the default
`BastionClass' will rarely be required.
File: pylibi, Node: Cryptographic Services, Next: RISCOS ONLY, Prev: Restricted Execution, Up: Top
Cryptographic Services
**********************
The modules described in this chapter implement various algorithms of a
cryptographic nature. They are available at the discretion of the
installation. Here's an overview:
-- RSA's MD5 message digest algorithm.
-- Interface to the GNU MP library for arbitrary precision
arithmetic.
rotor
-- Enigma-like encryption and decryption.
Hardcore cypherpunks will probably find the cryptographic modules
written by Andrew Kuchling of further interest; the package adds
built-in modules for DES and IDEA encryption, provides a Python module
for reading and decrypting PGP files, and then some. These modules are
not distributed with Python but available separately. See the URL
`http://www.magnet.com/~amk/python/pct.html' or send email to
`amk@magnet.com' for more information.
* Menu:
* md5::
* mpz::
* rotor::
File: pylibi, Node: md5, Next: mpz, Prev: Cryptographic Services, Up: Cryptographic Services
Built-in Module `md5'
=====================
This module implements the interface to RSA's MD5 message digest
algorithm (see also Internet RFC 1321). Its use is quite
straightforward: use the `md5.new()' to create an md5 object. You can
now feed this object with arbitrary strings using the `update()'
method, and at any point you can ask it for the "digest" (a strong kind
of 128-bit checksum, a.k.a. "fingerprint") of the contatenation of the
strings fed to it so far using the `digest()' method.
For example, to obtain the digest of the string "Nobody inspects the
spammish repetition":
>>> import md5
>>> m = md5.new()
>>> m.update("Nobody inspects")
>>> m.update(" the spammish repetition")
>>> m.digest()
'\273d\234\203\335\036\245\311\331\336\311\241\215\360\377\351'
More condensed:
>>> md5.new("Nobody inspects the spammish repetition").digest()
'\273d\234\203\335\036\245\311\331\336\311\241\215\360\377\351'
- function of module md5: new ([ARG])
Return a new md5 object. If ARG is present, the method call
`update(ARG)' is made.
- function of module md5: md5 ([ARG])
For backward compatibility reasons, this is an alternative name
for the `new()' function.
An md5 object has the following methods:
- Method on md5: update (ARG)
Update the md5 object with the string ARG. Repeated calls are
equivalent to a single call with the concatenation of all the
arguments, i.e. `m.update(a); m.update(b)' is equivalent to
`m.update(a+b)'.
- Method on md5: digest ()
Return the digest of the strings passed to the `update()' method
so far. This is an 16-byte string which may contain non-ASCII
characters, including null bytes.
- Method on md5: copy ()
Return a copy ("clone") of the md5 object. This can be used to
efficiently compute the digests of strings that share a common
initial substring.
File: pylibi, Node: mpz, Next: rotor, Prev: md5, Up: Cryptographic Services
Built-in Module `mpz'
=====================
This is an optional module. It is only available when Python is
configured to include it, which requires that the GNU MP software is
installed.
This module implements the interface to part of the GNU MP library,
which defines arbitrary precision integer and rational number
arithmetic routines. Only the interfaces to the *integer* (`mpz_...')
routines are provided. If not stated otherwise, the description in the
GNU MP documentation can be applied.
In general, "mpz"-numbers can be used just like other standard Python
numbers, e.g. you can use the built-in operators like `+', `*', etc.,
as well as the standard built-in functions like `abs', `int', ...,
`divmod', `pow'. *Please note:* the bitwise-xor operation has been
implemented as a bunch of ands, inverts and ors, because the library
lacks an `mpz_xor' function, and I didn't need one.
You create an mpz-number by calling the function called `mpz' (see
below for an exact description). An mpz-number is printed like this:
`mpz(VALUE)'.
- function of module mpz: mpz (VALUE)
Create a new mpz-number. VALUE can be an integer, a long, another
mpz-number, or even a string. If it is a string, it is interpreted
as an array of radix-256 digits, least significant digit first,
resulting in a positive number. See also the `binary' method,
described below.
A number of *extra* functions are defined in this module. Non
mpz-arguments are converted to mpz-values first, and the functions
return mpz-numbers.
- function of module mpz: powm (BASE, EXPONENT, MODULUS)
Return `pow(BASE, EXPONENT) % MODULUS'. If `EXPONENT == 0', return
`mpz(1)'. In contrast to the C-library function, this version can
handle negative exponents.
- function of modul