
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
uuid-random
Advanced tools
Generate RFC-4122 compliant random UUIDs (version 4) with better statistical dispersion than Math.random()
.
npm i uuid-random
Or download the latest release.
Compatible with almost all versions of:
The included benchmark.js
as well as independent benchmarks rank this library as the fastest pure JS UUID v4 generator available with cryptographically secure PRNG— almost 20x faster than the most popular library (using latest NodeJS).
npm package | performance |
---|---|
portable-uuid | 354k ops/sec |
uuid | 474k ops/sec |
id128 | 6.0M ops/sec |
uuid-random (this) | 9.7M ops/sec |
Results above generated on a 4.20GHz Intel i7-7700K with Node v12.18.0
Universally Unique IDentifiers transcend many constraints of traditional incremental integer IDs, especially in distributed systems. In UUID version 4, we essentially generate a random 128-bit value.
We do trade guaranteed uniqueness for extremely probable uniqueness (you would need to do-loop uuid()
at max speed for 73,067 years for a 50% chance of one collision). But for that slight cost, we may now generate valid, unique, persistent IDs on any node of a distributed system (e.g. intermittently offline or high-latency clients).
Note, if you plan to use UUIDs for a new project, depending on your requirements, you may consider a more recent standard that addresses some of the shortcomings of UUID, such as flake-id, nanoid, cuid, or ulid.
import uuid from 'uuid-random';
uuid(); // 'f32dc9ae-7ca8-44ca-8f25-f258f7331c55'
var uuid = require('uuid-random');
uuid(); // '0b99b82f-62cf-4275-88b3-de039020f14e'
<script src="uuid-random.min.js"></script>
<script>
uuid(); // 'b96ab5e6-f1e8-4653-ab08-4dd82ea65778'
</script>
uuid.test('0b99b82f-62cf-4275-88b3-de039020f14e'); // true
uuid.bin(); // <Buffer 41 db 10 54 b3 61 48 50 87 f1 2f 7b 08 a5 0f 06>
Feel free to open an issue or submit a pull request.
MIT.
FAQs
Fastest UUIDv4 with good RNG
The npm package uuid-random receives a total of 215,859 weekly downloads. As such, uuid-random popularity was classified as popular.
We found that uuid-random demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.