Python生成模数数字

2024-04-26 00:32:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要迭代生成数字x,它遵循以下条件

  • (x^z)模块n*x<;不
  • n是已知的,z在每个循环中都会变化

我之所以需要它,是因为我正在对RSA实施定时攻击,并且需要生成这样的数字来测量时间,而不需要模块化缩减
谢谢


Tags: 模块lt时间数字模块化条件rsa
1条回答
网友
1楼 · 发布于 2024-04-26 00:32:58

如果事先不知道z值的列表,您可能会为此尝试coroutine:

def compute_current(x, n, z):
    # some computation here

def crunch(x, n):
    current = x
    z = yield current
    while True:
        current = compute_current(current, n, z)
        z = yield current

c = crunch(x=10)
next(c)

new_x = crunch.send(some_z)
newer_x = crunch.send(some_other_z)
...

相关问题 更多 >