Changed code to use pycrypto's random number generator.