Much has been happening in the Node.js crypto subsystem lately. I introduced the Web Cryptography API implementation, and added the new support for the HKDF key derivation scheme previously. Here I discuss two powerful new capabilities for generating random UUIDs and random prime numbers. Read more: https://www.nearform.com/blog/new-crypto-capabilities-in-node-js/
import { randomUUID } from 'crypto'
console.log(randomUUID())const prime = crypto.generatePrimeSync(32)
console.log(prime)
// Or asynchronous ...
crypto.generatePrime(
32,
{ safe: true, add: 2n, rem: 1n, bigint: true },
(err, prime) => {
console.log(prime)
},
)