コード例 #1
0
ファイル: rand.py プロジェクト: eskimowallet/eskimo
def platformCheck(checks=1000):
	from collections import Counter
	print('Checking for good entropy')
	randList = []
	count = 0
	for zbit in xrange(checks):
		out.prnt('\b\b\b\b\b\b{0:4d}'.format(1000-count))
		count += 1
		randList.append(clockrnd())
	out.prnt('\b\b\b\b\b\b\b\b\b')
	duplicateCheck = Counter(randList).most_common(1)
	x, count = duplicateCheck[0]
	if count != 1:
		print('FAIL: time-based entropy is not always unique!')
		return False
	print('...pass')
	return True
コード例 #2
0
ファイル: inp.py プロジェクト: eskimowallet/eskimo
def secure_passphrase(msg):
	progress_step = 0
	pretty_progress = ['\b@', '\b#', '\b*', '\b!']
	keypress = get._Getch()
	single_key = passw = ''
	out.prnt(msg + ' :  ')
	
	while single_key != "\n" and single_key != chr(13):
		while True:
			single_key = keypress()
			if single_key != '':
				break
	   
		if single_key != "\n" and single_key != chr(13):
			passw += single_key
		out.prnt(pretty_progress[progress_step % 4])
		progress_step += 1
	print('\b')
	return passw
コード例 #3
0
ファイル: inp.py プロジェクト: eskimowallet/eskimo
def keyboardEntropy(keynum=64):
	"""
	512 bit random number from keyboard and keypress timer
	"""

	keypress = get._Getch()
	typed = kr = 'Press some keys to generate a secure address...'
	hashes = rand.clockrnd()
	print(kr)
	for step in range(keynum, 0, -1):
		for cnt in xrange(10000000):  # only loops on OSX
			hashes ^= rand.clockrnd()
			kr = keypress()
			get.flushKeybuffer(keypress)
			if kr != '':
				break
		typed += kr
		hashes ^= rand.clockrnd()
		out.prnt('\b\b\b\b\b\b{0:4d}\b\b\b\b\b'.format(step-1))
	get.flushKeybuffer(keypress)
	out.prnt('\b\b\b\b\b\b{0:4s}\b\b\b\b\b\n'.format('  OK'))
	get.flushKeybuffer(keypress)
	return hashes ^ int(hashlib.sha512(typed*8).hexdigest(), 16)