Package M2Crypto :: Module BN
[frames] | no frames]

Module BN



M2Crypto wrapper for OpenSSL BN (BIGNUM) API.

Copyright (c) 2005 Open Source Applications Foundation. All rights reserved.

Functions
 
rand(bits, top=-1, bottom=0)
Generate cryptographically strong random number.
 
rand_range(range)
Generate a random number in a range.
 
randfname(length)
Return a random filename, which is simply a string where all the characters are from the set [a-zA-Z0-9].
Function Details

rand(bits, top=-1, bottom=0)

 

Generate cryptographically strong random number.

Parameters:
  • bits - Length of random number in bits.
  • top - If -1, the most significant bit can be 0. If 0, the most significant bit is 1, and if 1, the two most significant bits will be 1.
  • bottom - If bottom is true, the number will be odd.

rand_range(range)

 

Generate a random number in a range.

Parameters:
  • range - Upper limit for range.
Returns:
A random number in the range [0, range)

randfname(length)

 

Return a random filename, which is simply a string where all the characters are from the set [a-zA-Z0-9].

Parameters:
  • length (int) - Length of filename to return.
Returns:
random filename string