コード例 #1
0
ファイル: main.py プロジェクト: deepworks/true-random
from quantumRandom import QuantumRandom
from randomDotOrg import RandomDotOrg

GENERATE = 4500 # CHANGE ME
MULT = 1*10**10

# Get a bunch of random numbers (like thousands) and store in a file
qr = QuantumRandom()
with open('quantumrandom.txt', 'a') as qrfile:
	for x in range(0,GENERATE):
		num = int(qr.random() * MULT)
		qrfile.write(str(num) + '\n')
	qrfile.close()
#except IOError as err:
#	print err
print 'Done Quantum Random'



rdo = RandomDotOrg()
before = rdo.checkBitQuota()

# max 1,000,000 bits per day. if we have any less than 10,000 that's critical
if before<10000:
	print 'We only have ' + str(before) + ' bits left today. Critically low - exiting!'
	exit()

with open('randomdotorg.txt', 'a') as rdofile:
	# get them all at once (easier)
	nums = rdo.random(GENERATE)
	for num in nums:
コード例 #2
0
from quantumRandom import QuantumRandom
from randomDotOrg import RandomDotOrg

GENERATE = 4500  # CHANGE ME
MULT = 1 * 10**10

# Get a bunch of random numbers (like thousands) and store in a file
qr = QuantumRandom()
with open('quantumrandom.txt', 'a') as qrfile:
    for x in range(0, GENERATE):
        num = int(qr.random() * MULT)
        qrfile.write(str(num) + '\n')
    qrfile.close()
#except IOError as err:
#	print err
print 'Done Quantum Random'

rdo = RandomDotOrg()
before = rdo.checkBitQuota()

# max 1,000,000 bits per day. if we have any less than 10,000 that's critical
if before < 10000:
    print 'We only have ' + str(
        before) + ' bits left today. Critically low - exiting!'
    exit()

with open('randomdotorg.txt', 'a') as rdofile:
    # get them all at once (easier)
    nums = rdo.random(GENERATE)
    for num in nums:
        num = int(num * MULT)
コード例 #3
0
ファイル: mai.py プロジェクト: igorrivin/true-random
	result = (tester.run_test_battery('random seeding twister', nums=nums))	
	result.display()
	
	# time seeding mersenne
	nums = []
	seeds = 100
	runs_per_seed = int(sample_size / seeds)
	for a in range(0,100):
		seed = timeseed.get_seed()
		nums.extend(twister.get_random_numbers(seed, runs_per_seed))
	result = (tester.run_test_battery('time seeding twister', nums=nums))	
	result.display()
	
	# quantum random seeding mersenne
	nums = []
	qr = QuantumRandom()
	seeds = 100
	runs_per_seed = int(sample_size / seeds)
	for a in range(0,100):
		seed = int(qr.random() * 2**30)
		# only use first few for seeding use each one to seed for 100 more
		nums.extend(twister.get_random_numbers(seed, runs_per_seed))
	result = (tester.run_test_battery('quantum seeding twister', nums=nums))
	result.display()	
		
	'''
	# default random
	results_list = []
	bits = 10
	for trialnum in range(0,trials):
		nums = [int(random.getrandbits(bits)) for x in range(0,sample_size)] # 0 -> 2**bits - 1