Skip to content

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

adrianer/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()
  • 1.1 added winrandom.bytes(num)
  • 1.2 added winrandom.range(max)

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

Languages

  • C 80.7%
  • Python 19.3%