我在编程中不知道,我需要修正代码,将“ M”和“ L”的值更改为由128位组成的随机数吗?
def extended_gcd(aa, bb):
lastremainder, remainder = abs(aa), abs(bb)
x, lastx, y, lasty = 0, 1, 1, 0
while remainder:
lastremainder, (quotient, remainder) = remainder, divmod(lastremainder, remainder)
x, lastx = lastx - quotient*x, x
y, lasty = lasty - quotient*y, y
return lastremainder, lastx * (-1 if aa < 0 else 1), lasty * (-1 if bb < 0 else 1)
def modinv(a, m):
g, x, y = extended_gcd(a, m)
if g != 1:
raise ValueError
return x % m
M = 0x5FFDF9E967A054B02E0C56CDCF816A98
L = 0x45C42EF3369B5F069C57B4FF54F307F1
with open("results.txt", 'w') as f:
print(hex(M*L), file=f)
答案 0 :(得分:0)
如果我正确理解了这个问题,那么您要做的就是:
import random
with open("results.txt", "w") as f:
for _ in range(num_of_rows): # num_of_rows is the number of such results you want to store, replace it by the number
M = random.randrange(16**32)
L = random.randrange(16**32)
print("0x{:066x}".format(M*L), file=f)