2003-05-01 05:35:20 +08:00
|
|
|
import rpm
|
|
|
|
|
2003-05-03 05:05:46 +08:00
|
|
|
rpm.rng().Debug(1);
|
2003-05-01 16:09:16 +08:00
|
|
|
#rpm.mpw().Debug(-1);
|
|
|
|
|
2003-05-03 05:05:46 +08:00
|
|
|
# Generate random intergers
|
2003-05-01 05:35:20 +08:00
|
|
|
r = rpm.rng()
|
2003-05-03 05:05:46 +08:00
|
|
|
for i in range(100):
|
2003-05-01 16:09:16 +08:00
|
|
|
print r.next()
|
2003-05-01 05:35:20 +08:00
|
|
|
|
2003-05-03 05:05:46 +08:00
|
|
|
# Generate random numbers with lots of bits
|
2003-05-01 16:09:16 +08:00
|
|
|
m = rpm.mpw("800000000000000000000000000000000000000000000000000000000000000000000000")
|
2003-05-03 05:05:46 +08:00
|
|
|
for i in range(100):
|
|
|
|
r.next(m)
|
|
|
|
|
|
|
|
# Generate 160 bit random primes
|
|
|
|
bits = 160
|
|
|
|
trials = -1
|
|
|
|
a = r.prime(bits, trials)
|
|
|
|
for i in range(100):
|
|
|
|
b = r.prime(bits, trials)
|
|
|
|
print a.gcd(a,b)
|
|
|
|
a = b
|