Skip to content

Commit 183a048

Browse files
authored
Refactor
1 parent 6c04620 commit 183a048

1 file changed

Lines changed: 9 additions & 12 deletions

File tree

hashes/chaos_machine.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515

1616
def push(seed):
17-
global buffer_space, params_space, machine_time, K, m, t
17+
global buffer_space, params_space, machine_time
1818

1919
# Choosing Dynamical Systems (All)
2020
for key, value in enumerate(buffer_space):
@@ -40,14 +40,7 @@ def push(seed):
4040

4141

4242
def pull():
43-
global buffer_space, params_space, machine_time, K, m, t
44-
45-
# PRNG (Xorshift by George Marsaglia)
46-
def xorshift(x, y):
47-
x ^= y >> 13
48-
y ^= x << 17
49-
x ^= y >> 5
50-
return x
43+
global buffer_space, params_space, machine_time
5144

5245
# Choosing Dynamical Systems (Increment)
5346
key = machine_time % m
@@ -69,11 +62,15 @@ def xorshift(x, y):
6962
# Machine Time
7063
machine_time += 1
7164

72-
return xorshift(x, y) % 0xFFFFFFFF
65+
# PRNG (Xorshift by George Marsaglia)
66+
x ^= y >> 13
67+
y ^= x << 17
68+
x ^= y >> 5
69+
return x 0xFFFFFFFF
7370

7471

7572
def reset():
76-
global buffer_space, params_space, machine_time, K, m, t
73+
global buffer_space, params_space, machine_time
7774

7875
buffer_space = K
7976
params_space = [0] * m
@@ -95,7 +92,7 @@ def reset():
9592
inp = ""
9693

9794
# Pulling Data (Output)
98-
while inp in ("e", "E"):
95+
while inp not in ("e", "E"):
9996
print(f"{format(pull(), '#04x')}")
10097
print(buffer_space)
10198
print(params_space)

0 commit comments

Comments
 (0)