跳到主要内容
uencoder

生成 prime numbers

生成 primes for cryptographic keys and number theory. Learn sieves, primality testing, and safe prime generation.

  1. 1

    素数 generation 方法: Sieve 的 Eratosthenes (所有 primes 上到 N, 高效为 小 primes), random 搜索 (生成 random odd 数字, 测试 primality, repeat — 为 crypto), Miller-Rabin (probabilistic primality 测试, 快和 accurate). 为 cryptography, 生成 1024-4096 位 primes using random 搜索 + Miller-Rabin.

  2. 2
    素数生成器 →

    生成 prime numbers. Specify the bit size (e.g., 1024, 2048) for cryptographic primes, or a range for small primes. The tool uses random search with Miller-Rabin testing — the generated primes are probable primes (error probability < 2^-100).

  3. 3
    素数检查器 →

    Verify generated 数字是 素数. checker 我们 Miller-Rabin 具有多个 rounds — 更多 rounds increase confidence. 为 cryptographic use, 40-64 rounds give negligible 假-正概率. 为 absolute certainty, use AKS 测试 (deterministic 但慢).

常见问题

什么是 安全素数?
素数 p where (p-1)/2 是 also 素数. 安全 primes 是 used 在 Diffie-Hellman 到 prevent 确定 attacks (Pohlig-Hellman). Generating 安全 primes 是 slower — 生成 p, 检查如果 (p-1)/2 是素数, repeat. 为最多 applications, regular primes 是充分; use 安全 primes 为 DH 组 generation.
如何 random 必须 crypto primes 是?
Very random. 如果素数 generation 是 predictable (e.g., sequential, 低 entropy seed), attacker 能够 guess primes 和 break 键. Use CSPRNG 为 random 搜索. Avoid primes 具有特殊结构 (smooth p-1) — 这些是 vulnerable 到 specialized attacks. RFC 5234 specifies requirements 为 DSA primes.

相关工具