• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

Doc/H14-Oct-2013-1,217962

LEGAL/H03-May-2022-1,9231,686

lib/Crypto/H14-Oct-2013-19,66112,697

src/H14-Oct-2013-16,69712,556

ACKSH A D24-May-20121 KiB5952

COPYRIGHTH A D14-Oct-20133.1 KiB7054

ChangeLogH A D14-Oct-201324.4 KiB700494

MANIFEST.inH A D14-Oct-2013174 87

PKG-INFOH A D14-Oct-2013666 2019

READMEH A D14-Oct-20134 KiB10481

TODOH A D24-May-2012991 3121

configureH A D14-Oct-2013137.5 KiB4,9264,055

configure.acH A D14-Oct-20131.3 KiB5848

pct-speedtest.pyH A D14-Oct-20137.7 KiB222154

setup.pyH A D03-May-202217.7 KiB475332

README

1Python Cryptography Toolkit (pycrypto)
2======================================
3
4This is a collection of both secure hash functions (such as SHA256 and
5RIPEMD160), and various encryption algorithms (AES, DES, RSA, ElGamal,
6etc.).  The package is structured to make adding new modules easy.
7This section is essentially complete, and the software interface will
8almost certainly not change in an incompatible way in the future; all
9that remains to be done is to fix any bugs that show up.  If you
10encounter a bug, please report it in the Launchpad bug tracker at
11
12       https://launchpad.net/products/pycrypto/+bugs
13
14An example usage of the SHA256 module is:
15>>> from Crypto.Hash import SHA256
16>>> hash = SHA256.new()
17>>> hash.update('message')
18>>> hash.digest()
19'\xabS\n\x13\xe4Y\x14\x98+y\xf9\xb7\xe3\xfb\xa9\x94\xcf\xd1\xf3\xfb"\xf7\x1c\xea\x1a\xfb\xf0+F\x0cm\x1d'
20
21An example usage of an encryption algorithm (AES, in this case) is:
22
23>>> from Crypto.Cipher import AES
24>>> obj = AES.new('This is a key456', AES.MODE_ECB)
25>>> message = "The answer is no"
26>>> ciphertext = obj.encrypt(message)
27>>> ciphertext
28'o\x1aq_{P+\xd0\x07\xce\x89\xd1=M\x989'
29>>> obj2 = AES.new('This is a key456', AES.MODE_ECB)
30>>> obj2.decrypt(ciphertext)
31'The answer is no'
32
33One possible application of the modules is writing secure
34administration tools.  Another application is in writing daemons and
35servers.  Clients and servers can encrypt the data being exchanged and
36mutually authenticate themselves; daemons can encrypt private data for
37added security.  Python also provides a pleasant framework for
38prototyping and experimentation with cryptographic algorithms; thanks
39to its arbitrary-length integers, public key algorithms are easily
40implemented.
41
42As of PyCrypto 2.1.0, PyCrypto provides an easy-to-use random number
43generator:
44
45>>> from Crypto import Random
46>>> rndfile = Random.new()
47>>> rndfile.read(16)
48'\xf7.\x838{\x85\xa0\xd3>#}\xc6\xc2jJU'
49
50A stronger version of Python's standard "random" module is also
51provided:
52
53>>> from Crypto.Random import random
54>>> random.choice(['dogs', 'cats', 'bears'])
55'bears'
56
57Caveat: For the random number generator to work correctly, you must
58call Random.atfork() in both the parent and child processes after
59using os.fork()
60
61
62Installation
63============
64
65PyCrypto is written and tested using Python version 2.1 through 3.2.  Python
661.5.2 is not supported.
67
68The modules are packaged using the Distutils, so you can simply run
69"python setup.py build" to build the package, and "python setup.py
70install" to install it.
71
72If the setup.py script crashes with a DistutilsPlatformError
73complaining that the file /usr/lib/python2.2/config/Makefile doesn't
74exist, this means that the files needed for compiling new Python
75modules aren't installed on your system.  Red Hat users often run into
76this because they don't have the python2-devel RPM installed.  The fix
77is to simply install the requisite RPM.  On Debian/Ubuntu, you need the
78python-dev package.
79
80To verify that everything is in order, run "python setup.py test".  It
81will test all the cryptographic modules, skipping ones that aren't
82available.  If the test script reports an error on your machine,
83please report the bug using the bug tracker (URL given above).  If
84possible, track down the bug and include a patch that fixes it,
85provided that you are able to meet the eligibility requirements at
86http://www.pycrypto.org/submission-requirements/.
87
88It is possible to test a single sub-package or a single module only, for instance
89when you investigate why certain tests fail and don't want to run the whole
90suite each time. Use "python setup.py test --module=name", where 'name'
91is either a sub-package (Cipher, PublicKey, etc) or a module (Cipher.DES,
92PublicKey.RSA, etc).
93To further cut test coverage, pass also the option "--skip-slow-tests".
94
95To install the package under the site-packages directory of
96your Python installation, run "python setup.py install".
97
98If you have any comments, corrections, or improvements for this
99package, please report them to our mailing list, accessible via the
100PyCrypto website:
101
102    http://www.pycrypto.org/
103
104