首页Home › 随机生成Random Generators
🎲 随机性检验(序列是否随机)Randomness Test (Is This Sequence Random?)
检验一串数据看起来是否随机:比特串(0/1)按 NIST SP 800-22 做频数、游程、块内最长游程检验;整数序列(如掷骰子、抽号结果)做均匀分布 χ²、平均值、升降游程和相邻相关检验;文本、十六进制、Base64 字符串(如密钥、令牌)计算熵和字符分布。给出每项 p 值和总体结论,全部在浏览器本地计算。Check whether a sequence looks random. Bit strings (0/1) get the NIST SP 800-22 frequency, runs and longest-run-in-a-block tests; integer sequences (dice rolls, lottery draws) get uniformity χ², mean, runs up and down and serial correlation; text, hex and Base64 strings (keys, tokens) get entropy and character-distribution tests. Each test shows its p-value and there is an overall verdict. Everything is computed locally in your browser.
使用说明与常见问题How-to & FAQ
「随机性检验(序列是否随机)」是什么?What is the Randomness Test (Is This Sequence Random?) tool?
检验一串数据看起来是否随机:比特串(0/1)按 NIST SP 800-22 做频数、游程、块内最长游程检验;整数序列(如掷骰子、抽号结果)做均匀分布 χ²、平均值、升降游程和相邻相关检验;文本、十六进制、Base64 字符串(如密钥、令牌)计算熵和字符分布。给出每项 p 值和总体结论,全部在浏览器本地计算。Check whether a sequence looks random. Bit strings (0/1) get the NIST SP 800-22 frequency, runs and longest-run-in-a-block tests; integer sequences (dice rolls, lottery draws) get uniformity χ², mean, runs up and down and serial correlation; text, hex and Base64 strings (keys, tokens) get entropy and character-distribution tests. Each test shows its p-value and there is an overall verdict. Everything is computed locally in your browser.
如何使用「随机性检验(序列是否随机)」?How do I use the Randomness Test (Is This Sequence Random?) tool?
在「随机性检验(序列是否随机)」中,把内容粘贴或输入到上方输入框,按需设置「数据类型」、「显著性水平」、「可能的最小值(整数,可选)」、「可能的最大值(整数,可选)」,结果会实时显示在下方,点击「复制结果」即可复制。In the Randomness Test (Is This Sequence Random?): Paste or type into the input box, adjust "Data type", "Significance level", "Smallest possible value (integers, optional)", "Largest possible value (integers, optional)"; the result appears below instantly — click "Copy result" to copy it.
p 值是什么意思?结论怎么看?What does the p-value mean, and how do I read the verdict?
p 值表示“如果数据真的随机,出现至少这么极端结果的概率”。p 小于显著性水平(默认 0.01)就标 ✖,说明这项检验发现了不像随机的规律;p 较大标 ✔。注意:即使数据完全随机,每项检验也有约 1% 的机会误报 ✖;反过来,全部通过也只能说明“没有发现问题”,不能证明一定随机。The p-value is the probability of a result at least this extreme if the data really were random. A p below the significance level (0.01 by default) is marked ✖: that test found a pattern unlike randomness. A larger p is marked ✔. Even perfectly random data trips each test about 1% of the time, and passing every test only means no problem was found — it can't prove randomness.
需要多少数据?How much data is needed?
越多越可靠。比特串 NIST 建议至少 100 位,块内最长游程检验需要 128 位以上;整数的 χ² 检验要求每个可能取值平均至少出现 5 次(例如骰子 1–6 至少约 30 次,实际最好几百次以上);字节的 χ² 至少需要 1,280 个字节。数据不够时相应检验会显示“未进行”和原因。More is better. NIST recommends at least 100 bits, and the longest-run test needs 128 or more. The integer χ² test needs at least 5 expected occurrences of each possible value (about 30 rolls for a 1–6 die, ideally hundreds), and the byte χ² test needs at least 1,280 bytes. When there isn't enough data, the test shows "not run" with the reason.
为什么要填“可能的最小值 / 最大值”?Why fill in the smallest / largest possible value?
工具默认用数据里出现的最小值和最大值作为取值范围。如果某些值从未出现(例如骰子从没掷出 6),这样会漏掉问题;填上真实范围(1 和 6)后,χ² 和平均值检验会按完整范围计算。By default the range is the smallest and largest values that appear. If some values never appear (a die that never rolls 6, say), that hides the problem; enter the true range (1 and 6) and the χ² and mean tests use the full range.
能检验密码、密钥或令牌吗?Can it test passwords, keys or tokens?
可以做初步检查:十六进制和 Base64 字符串会自动按它们的 16 或 64 个字符检验熵和分布,普通文本按 UTF-8 字节检验。但统计检验只能发现明显的规律,不能证明密钥安全;生成密钥请使用密码学安全的随机数生成器。数据只在本地处理,不会上传。As a first check, yes: hex and Base64 strings are automatically tested over their 16 or 64 characters for entropy and distribution, and other text as UTF-8 bytes. Statistical tests only catch obvious patterns and can't prove a key is secure, so generate keys with a cryptographically secure random generator. The data is processed locally and never uploaded.
随机结果真的随机吗?Is the randomness truly random?
「随机性检验(序列是否随机)」在涉及安全的场景使用浏览器的 crypto.getRandomValues(密码学安全随机数),其余使用 Math.random。The Randomness Test (Is This Sequence Random?) uses crypto.getRandomValues (cryptographically secure) where it matters and Math.random elsewhere.
「随机性检验(序列是否随机)」免费吗?需要注册吗?Is the Randomness Test (Is This Sequence Random?) free? Do I need an account?
「随机性检验(序列是否随机)」完全免费,无需注册或安装,打开网页即可使用,手机和电脑都能用;输入的内容只在你的浏览器本地处理。The Randomness Test (Is This Sequence Random?) is completely free with no sign-up or install and works on phones and desktops; what you enter is processed only in your browser.