Created
August 10, 2018 10:43
-
-
Save gynvael/ecf3e3ac2d55e6a38f600fcaea16cda3 to your computer and use it in GitHub Desktop.
Vlog #012 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
M = [13023, 201527, 4294967291] | |
N = [ | |
21179556,5337795,18437072, | |
11383457,16076557,13286032, | |
37655692,471675,21030418, | |
33533337,9666873,6884524,111490, | |
18371648 | |
] | |
mm = "" | |
nn = "" | |
kk = "" | |
for n in N: | |
res = (n * M[0] + M[1]) | |
print " " | |
res1 = res % (M[2]) | |
res2 = res / M[2] | |
print "res=%15i %10x, res2=%3i %2x, res1=%15i %10x" % (res, res, res2, res2, res1, res1), | |
res = res1 | |
a = hex(res) | |
if a.startswith('-'): | |
a = a[1:] | |
a = a[2:] | |
if a.endswith('L'): | |
a = a[:-1] | |
while len(a) % 2 != 0: | |
a = '0' + a | |
res3 = (res * M[0] + M[1]) % M[2] | |
res4 = (res3 * M[0] + M[1]) % M[2] | |
nn += chr(res & 0xff) + chr(res3 & 0xff) + chr(res4 & 0xff) | |
mm += a | |
#print a, | |
kk += str(res) + " " | |
print "\n" | |
#print kk | |
print nn | |
#print mm.decode("hex") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
M = [13023, 201527, 4294967291] | |
N = [ | |
21179556,5337795,18437072, | |
11383457,16076557,13286032, | |
37655692,471675,21030418, | |
33533337,9666873,6884524,111490, | |
18371648 | |
] | |
for m in M: | |
print m, len(bin(m))-2, hex(m) | |
for n in N: | |
print n, len(bin(n))-2, hex(n) | |
ops = [ | |
lambda x, y: x + y, # 0 | |
lambda x, y: x - y, # 1 | |
lambda x, y: x ^ y, # 2 | |
lambda x, y: x & y, # 3 | |
lambda x, y: x / y, # 4 | |
lambda x, y: x % y, # 5 | |
lambda x, y: x * y, # 6 | |
lambda x, y: x, # 7 | |
lambda x, y: y, # 8 | |
] | |
for i, o in enumerate(ops): | |
for j, p in enumerate(ops): | |
for k, r in enumerate(ops): | |
print i, j, k, "-" * 70 | |
mm = "" | |
nn = "" | |
kk = "" | |
for n in N: | |
res = r(p(o(n, M[0]), M[1]), M[2]) | |
a = hex(res) | |
if a.startswith('-'): | |
a = a[1:] | |
a = a[2:] | |
if a.endswith('L'): | |
a = a[:-1] | |
while len(a) % 2 != 0: | |
a = '0' + a | |
nn += chr(res & 0xff) | |
mm += a | |
#print a, | |
kk += str(res) + " " | |
print "" | |
#print kk | |
print nn | |
#print mm.decode("hex") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment