4 from Crypto.Util.number import *
10 r = random.randint(0, nbit-1)
18 rbit += (R[i+1] - R[i] - 1) * '0' + '1'
19 rbit += (nbit - R[-1] - 1) * '0'
24 f, skey = gen_rand(n, l), gen_rand(n, l)
25 pkey = f * inverse(skey, p) % p
26 return (p, pkey), skey
28 def encrypt(msg, pkey):
30 msg, enc, n = bytes_to_long(msg), [], len(bin(p)[2:])
31 for b in bin(msg)[2:]:
32 s, t = gen_rand(n, l), gen_rand(n, l)
40 p = 862718293348820473429344482784628181556388621521298319395315527974911
43 pkey, skey = genkey(p, l)
44 enc = encrypt(flag, pkey)