Skip to content
This repository has been archived by the owner on May 12, 2022. It is now read-only.
/ winrandom Public archive

Python module gives direct access to Windows Cryptographic API CryptGetRandom() function. It returns either a string of random bytes of arbitrary length, or a long integer.

Notifications You must be signed in to change notification settings

kravietz/winrandom

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

winrandom

This module gives direct access to Windows Cryptographic API CryptGetRandom() function, which is cryptographically strong pseudo-random number generator (PRNG) on Windows:

  • long() returns random unsigned long integer

      >>> import winrandom
      >>> winrandom.long()
      2141228967
    
  • bytes(n) returns n random bytes

      >>> winrandom.bytes(10)
      "\x1e'^';]\xda\xf0\x91\xba"
    
  • range(max) returns a random integer i from range 0 to max (0 <= i < max). Random data originates from the PRNG but to ensure that the integer is not biased an algorithm from NIST SP800-90 is used (B.5.1.1 Simple Discard Method). In addition, in the internal loop a continuous random number generator test is executed (FIPS 140-2 p. 44).

      >>> winrandom.range(1000)
      706
    

History

  • 1.0 added winrandom.long(), first published at IPSec.pl
  • 1.1 added winrandom.bytes(num)
  • 1.2 added winrandom.range(max)

Note

This module is obsolete since Python 2.4 when os.urandom was added to provide operating system based randomness on all supported systems.

About

Python module gives direct access to Windows Cryptographic API CryptGetRandom() function. It returns either a string of random bytes of arbitrary length, or a long integer.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published