Package Crypto :: Package Util :: Module number
[hide private]
[frames] | no frames]

Module number

Functions [hide private]
 
size(N)
size(N:long) : int Returns the size of the number N in bits.
 
getRandomNumber(N, randfunc)
getRandomNumber(N:int, randfunc:callable):long Return an N-bit random number.
 
GCD(x, y)
GCD(x:long, y:long): long Return the GCD of x and y.
 
inverse(u, v)
inverse(u:long, u:long):long Return the inverse of u mod v.
 
getPrime(N, randfunc)
getPrime(N:int, randfunc:callable):long Return a random N-bit prime number.
 
isPrime(N)
isPrime(N:long):bool Return true if N is prime.
 
long_to_bytes(n, blocksize=0)
long_to_bytes(n:long, blocksize:int) : string Convert a long integer to a byte string.
 
bytes_to_long(s)
bytes_to_long(string) : long Convert a byte string to a long integer.
 
long2str(n, blocksize=0)
 
str2long(s)
Variables [hide private]
  __revision__ = '$Id$'
  sieve = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 4...
Function Details [hide private]

long_to_bytes(n, blocksize=0)

 

long_to_bytes(n:long, blocksize:int) : string Convert a long integer to a byte string.

If optional blocksize is given and greater than zero, pad the front of the byte string with binary zeros so that the length is a multiple of blocksize.

bytes_to_long(s)

 

bytes_to_long(string) : long Convert a byte string to a long integer.

This is (essentially) the inverse of long_to_bytes().


Variables Details [hide private]

sieve

Value:
[2,
 3,
 5,
 7,
 11,
 13,
 17,
 19,
...