Bytes to long python

Module number

getRandomInteger(N:int, randfunc:callable):long Return a random number with at most N bits.

If randfunc is omitted, then Random.new().read is used.

This function is for internal use only and may be renamed or removed in the future.

getRandomRange ( a , b , randfunc = None )

getRandomRange(a:int, b:int, randfunc:callable):long Return a random number n so that a

If randfunc is omitted, then Random.new().read is used.

This function is for internal use only and may be renamed or removed in the future.

getRandomNBitInteger ( N , randfunc = None )

getRandomInteger(N:int, randfunc:callable):long Return a random number with exactly N-bits, i.e. a random number between 2**(N-1) and (2**N)-1.

If randfunc is omitted, then Random.new().read is used.

This function is for internal use only and may be renamed or removed in the future.

getPrime ( N , randfunc = None )

getPrime(N:int, randfunc:callable):long Return a random N-bit prime number.

If randfunc is omitted, then Random.new().read is used.

getStrongPrime ( N , e = 0 , false_positive_prob = 1e-06 , randfunc = None )

getStrongPrime(N:int, e:int, false_positive_prob:float, randfunc:callable):long Return a random strong N-bit prime number. In this context p is a strong prime if p-1 and p+1 have at least one large prime factor. N should be a multiple of 128 and > 512.

If e is provided the returned prime p-1 will be coprime to e and thus suitable for RSA where e is the public exponent.

The optional false_positive_prob is the statistical probability that true is returned even though it is not (pseudo-prime). It defaults to 1e-6 (less than 1:1000000). Note that the real probability of a false-positive is far less. This is just the mathematically provable limit.

Читайте также:  Scaling image size css

randfunc should take a single int parameter and return that many random bytes as a string. If randfunc is omitted, then Random.new().read is used.

isPrime ( N , false_positive_prob = 1e-06 , randfunc = None )

isPrime(N:long, false_positive_prob:float, randfunc:callable):bool Return true if N is prime.

The optional false_positive_prob is the statistical probability that true is returned even though it is not (pseudo-prime). It defaults to 1e-6 (less than 1:1000000). Note that the real probability of a false-positive is far less. This is just the mathematically provable limit.

If randfunc is omitted, then Random.new().read is used.

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().

sieve_base

Источник

Оцените статью