[pycrypto] RandomPool is now deprecated

Dwayne C. Litzenberger dlitz at dlitz.net
Wed Sep 17 22:23:58 CST 2008


At long last, using RandomPool now results in a DeprecationWarning.  The 
recommended way to get random bytes in new programs is to do something like 
this:

     from Crypto import Random
     ...
     rng = Random.new()      # rng is a file-like object
     ...
     data = rng.read(32)

This is okay too:

     from Crypto import Random
     ...
     data = Random.new().read(32)

If you need a drop-in replacement for old code that uses the RandomPool 
interface, you can replace this:

     from Crypto.Util.randpool import RandomPool

with this:

     from Crypto.Random import RandomPoolCompat as RandomPool

The new code will be included in the next release of PyCrypto, and is 
currently available in the git repository[1].  Please let me know if you 
find any problems.

On POSIX systems (where os.name == "posix"), we currently just read from 
/dev/urandom.  That should work well enough on the free *nix platforms 
(Linux, modern BSDs, etc.), but please let me know if there are any systems 
with bad /dev/urandom devices.

Cheers,
  - Dwayne

[1] git://git.pycrypto.org:9419/crypto/pycrypto-2.0.x.git
     http://gitweb.pycrypto.org/?p=crypto/pycrypto-2.0.x.git
     latest commit-id: 2d3846eefd728d6cf9fd9aa9f8e94d1a77107908

-- 
Dwayne C. Litzenberger <dlitz at dlitz.net>
  Key-signing key   - 19E1 1FE8 B3CF F273 ED17  4A24 928C EC13 39C2 5CF7
  Annual key (2008) - 4B2A FD82 FC7D 9E38 38D9  179F 1C11 B877 E780 4B45
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
Url : http://lists.dlitz.net/pipermail/pycrypto/attachments/20080918/9f1e0a6c/attachment.pgp 


More information about the pycrypto mailing list