如何在值中固定代码,以便有随机数?

问题描述 投票:-3回答:1

我不知道在编程中,我需要修正代码,在“ 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)
python math random neural-network
1个回答
0
投票

如果我正确理解了这个问题,那么您要做的就是:

import random

M = hex(random.randrange(16**32))
L = hex(random.randrange(16**32))
© www.soinside.com 2019 - 2024. All rights reserved.