首页Home › 随机生成Random Generators
🔐 随机质数生成器Random Prime Generator
在指定范围内随机生成质数(最大到 2^53),可一次生成多个、去重、排序;大数用确定性 Miller–Rabin 检验,结果严格是质数且均匀分布。Generate random prime numbers in any range up to 2^53 — several at once, unique and sorted if you like. Large numbers use a deterministic Miller–Rabin test, so every result is truly prime and uniformly chosen.
使用说明与常见问题How-to & FAQ
「随机质数生成器」是什么?What is the Random Prime Generator tool?
在指定范围内随机生成质数(最大到 2^53),可一次生成多个、去重、排序;大数用确定性 Miller–Rabin 检验,结果严格是质数且均匀分布。Generate random prime numbers in any range up to 2^53 — several at once, unique and sorted if you like. Large numbers use a deterministic Miller–Rabin test, so every result is truly prime and uniformly chosen.
如何使用「随机质数生成器」?How do I use the Random Prime Generator tool?
在「随机质数生成器」中,按需设置「最小值」、「最大值」、「数量」等选项,然后点击「生成」、「复制」按钮即可。In the Random Prime Generator: Set "Minimum", "Maximum", "Count", then click "Generate", "Copy".
怎么保证生成的一定是质数?How do you know the results are prime?
小于 1369 时用试除法;更大的数用以前 12 个质数为底的 Miller–Rabin 检验,这组底数对 318,665,857,834,031,151,167,461(约 3.19 × 10^23)以下的所有整数都是确定性的(Sorenson 与 Webster,2015 年《Mathematics of Computation》),因此在本工具的范围(2^53 ≈ 9.0 × 10^15 以内)不会误判。Below 1369 trial division is used. Larger numbers use Miller–Rabin with the first 12 primes as bases, which is deterministic for every integer below 318,665,857,834,031,151,167,461 (about 3.19 × 10^23; Sorenson and Webster, Mathematics of Computation, 2015), so there are no false positives in this tool's range (below 2^53, about 9.0 × 10^15).
随机是均匀的吗?Is the choice uniform?
范围较小(≤ 200 万个整数)时,先列出全部质数再等概率抽取;范围更大时,随机抽整数并丢弃合数(拒绝采样),每个质数被选中的概率也相同。For small ranges (up to 2 million integers) all primes are listed and one is picked with equal probability. For larger ranges random integers are drawn and composites discarded (rejection sampling), which is also uniform over the primes.
为什么限制在 2^53 以内?Why the 2^53 limit?
JavaScript 的普通数字只能精确表示 2^53 − 1 以内的整数,超过后相邻整数无法区分;如需更大的质数(如 RSA 密钥),请使用专门的密码学工具。JavaScript numbers represent integers exactly only up to 2^53 - 1; beyond that, neighbouring integers blur together. For larger primes such as RSA keys, use a dedicated cryptography tool.
随机结果真的随机吗?Is the randomness truly random?
「随机质数生成器」使用浏览器的 crypto.getRandomValues(密码学安全随机数)生成结果,并做了无偏处理,每个结果出现的概率相同。The Random Prime Generator uses crypto.getRandomValues (cryptographically secure randomness) with unbiased sampling, so every outcome is equally likely.
「随机质数生成器」免费吗?需要注册吗?Is the Random Prime Generator free? Do I need an account?
「随机质数生成器」完全免费,无需注册或安装,打开网页即可使用,手机和电脑都能用;输入的内容只在你的浏览器本地处理。The Random Prime Generator is completely free with no sign-up or install and works on phones and desktops; what you enter is processed only in your browser.