-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrand_test.py
72 lines (58 loc) · 1.4 KB
/
rand_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env python
import random
import base64
from libs import arc4random
from pynput import mouse
import time
import os
poolsize = 256
randPool = random.sample(range(256), poolsize)
pptr = 0
entropy = 0
def on_move(x, y):
timeS = time.time() - int(time.time())
global entropy
global randPool
seedInt16(x * y)
seedInt(int(timeS * 1000000000))
os.system('cls') # on windows
print("XY: " + str(x*y))
print("Time: " + str(int(timeS * 1000000000)))
print("Gathering entropy ... " + str(entropy) + " bytes gathered")
print(base64.b64encode(bytearray(randPool)))
if (entropy > 1024):
return False
def on_click(x, y, button, pressed):
return False
def on_scroll(x, y, dx, dy):
print('Scrolled {0} at {1}'.format(
'down' if dy < 0 else 'up',
(x, y)))
def seedInt (x):
seedInt8(x)
seedInt8((x >> 8))
seedInt8((x >> 16))
seedInt8((x >> 24))
def seedInt16 (x):
seedInt8(x)
seedInt8((x >> 8))
def seedInt8 (x):
global poolsize
global randPool
global entropy
global pptr
randPool[pptr] ^= x & 255
entropy += 1
pptr += 1
if (pptr >= poolsize):
pptr -= poolsize
# Collect events until released
with mouse.Listener(
on_move=on_move,
on_click=on_click,
on_scroll=on_scroll) as listener:
listener.join()
arc4random.rand(randPool)
p = arc4random.getrandbits(512)
print("")
print(base64.b64encode(p))