whoever invented tabs should swim in a bathtub full of space bars
parent
bdc3a05a93
commit
e42f03d58e
|
@ -4,18 +4,18 @@ import struct
|
||||||
from Crypto.PublicKey import RSA
|
from Crypto.PublicKey import RSA
|
||||||
|
|
||||||
def egcd(a, b):
|
def egcd(a, b):
|
||||||
if a == 0:
|
if a == 0:
|
||||||
return (b, 0, 1)
|
return (b, 0, 1)
|
||||||
else:
|
else:
|
||||||
g, y, x = egcd(b % a, a)
|
g, y, x = egcd(b % a, a)
|
||||||
return (g, x - (b // a) * y, y)
|
return (g, x - (b // a) * y, y)
|
||||||
|
|
||||||
def modinv(a, m):
|
def modinv(a, m):
|
||||||
g, x, y = egcd(a, m)
|
g, x, y = egcd(a, m)
|
||||||
if g != 1:
|
if g != 1:
|
||||||
raise Exception('modular inverse does not exist')
|
raise Exception('modular inverse does not exist')
|
||||||
else:
|
else:
|
||||||
return x % m
|
return x % m
|
||||||
|
|
||||||
def to_c_string(x):
|
def to_c_string(x):
|
||||||
mod = (hex(x)[2:-1].rjust(0x100, '0'))
|
mod = (hex(x)[2:-1].rjust(0x100, '0'))
|
||||||
|
|
Loading…
Reference in New Issue