crypto.getRandomValues,而非 Math.random。Random String Generator - Generate secure random strings with custom length and character sets (upper/lower/digit/symbol), batch output and one-click copy. U...
| Item | Formula / Note | Source / Standard |
|---|---|---|
| Entropy | H = L * log2(N) for length L and alphabet size N | NIST SP 800-63B |
| Alphabet | removing confusables lowers entropy; lengthen instead | NIST SP 800-63B |
| Random source | use a CSPRNG, never timestamps or counters | NIST SP 800-90A |
| 用途 | 建议 |
|---|---|
| 临时令牌 | 16–32 位,含大小写+数字+符号 |
| 测试数据 | 8–16 位即可 |
| 盐值(salt) | ≥16 位随机 |