跳到主要内容
uencoder

Use Extended Euclidean Algorithm

Extended GCD finds x, y such 该 ax + 通过 = gcd(, b). 必要为 modular inverses 和 Chinese Remainder Theorem.

  1. 1

    Extended Euclidean Algorithm computes gcd(, b) 和 finds Bézout coefficients x, y such 该 *x + b*y = gcd(, b). 如果 gcd(, b) = 1, 然后 x 是 modular inverse 的 mod b (*x ≡ 1 mod b). 此是 used 在 RSA (d = e^(-1) mod φ(n)), CRT, 和 solving 线性 Diophantine equations.

  2. 2
    最大公约数计算器 →

    计算 the GCD and Bézout coefficients. Enter a and b — the tool returns gcd(a,b), x, and y where a*x + b*y = gcd. Verify: if gcd = 1, then x mod b is the modular inverse of a mod b.

  3. 3
    模逆元计算器 →

    计算 the modular inverse directly. Given a and m, find a^(-1) mod m such that a * a^(-1) ≡ 1 mod m. The inverse exists if and only if gcd(a, m) = 1. This uses the Extended GCD internally.

常见问题

当 modular inverse 存在?
有 inverse mod m 如果和 仅如果 gcd(, m) = 1 ( 和 m 是 coprime). 如果 gcd(, m) > 1, 否 inverse exists. 为素数 m, 每个 non-零元素有 inverse. 为 composite m, 仅 elements coprime 到 m 有 inverses — 那里是 φ(m) such elements.
如何是 Extended GCD used 在 RSA?
RSA 键 generation: 选择 e (公共 exponent, 通常 65537), 计算 d = e^(-1) mod φ(n) where φ(n) = (p-1)(q-1). d 是私有 exponent, computed using Extended GCD: 查找 d, k such 该 e*d + φ(n)*k = 1, 然后 d mod φ(n) 是私有键.

相关工具