Skip to content
Myr

Clean up Security section

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Andrey Sitnik · committed by Andrey Sitnik · parent 88c2127 · Browse files · 1 file+12 added−26 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+12 added−26 removed

  • other:+12 added−26 removed

1 file+12 added−26 removed

modified:README.md+12 added-26 removed
35 unmodified lines
36* [Comparison with UUID](#comparison-with-uuid)37* [Benchmark](#benchmark)38* [Tools](#tools)39* [Security](#security)40 * [Unpredictability](#unpredictability)41 * [Uniformity](#uniformity)42 * [Vulnerabilities](#vulnerabilities)40* [Usage](#usage)41 * [JS](#js)42 * [React](#react)43 * [React Native](#react-native)
67 unmodified lines
111*See a good article about random generators theory:112[Secure random values (in Node.js)]*113114118### Unpredictability115* **Unpredictability.** Instead of using the unsafe `Math.random()`, Nano ID116 uses the `crypto` module in Node.js and the Web Crypto API in browsers.117 These modules use unpredictable hardware random generator.118* **Uniformity.** `random % alphabet` is a popular mistake to make when coding119 an ID generator. The spread will not be even; there will be a lower chance120 for some symbols to appear compared to others—so it will reduce the number121 of tries when brute-forcing. Nano ID uses a [better algorithm] and is tested for uniformity.122120Instead of using the unsafe `Math.random()`, Nano ID uses the `crypto` module121in Node.js and the Web Crypto API in browsers. These modules use unpredictable122hardware random generator.123124125### Uniformity126127`random % alphabet` is a popular mistake to make when coding an ID generator.128The spread will not be even; there will be a lower chance for some symbols129to appear compared to others—so it will reduce the number of tries130when brute-forcing.131132Nano ID uses a [better algorithm] and is tested for uniformity.133134<img src="img/distribution.png" alt="Nano ID uniformity"123 <img src="img/distribution.png" alt="Nano ID uniformity"124 width="340" height="135">125126* **Vulnerabilities:** to report a security vulnerability, please use127 the [Tidelift security contact](https://tidelift.com/security).128 Tidelift will coordinate the fix and disclosure.129130[Secure random values (in Node.js)]: https://gist.github.com/joepie91/7105003c3b26e65efcea63f3db82dfba131[better algorithm]: https://github.com/ai/nanoid/blob/master/format.js132133141### Vulnerabilities142143To report a security vulnerability, please use the144[Tidelift security contact](https://tidelift.com/security).145Tidelift will coordinate the fix and disclosure.146147134## Usage135136### JS137
252 unmodified lines