…and using TypeScript syntax. Simply use the “crypto” standard library.
import * as crypto from 'crypto'; const randomString = crypto.randomBytes(32).toString('hex');
Note that it will produce cryptographically strong pseudo-random data, but the drawback of this is that it will freeze a bit in case of a lack of entropy. As mentioned in the documentation, such lack of entropy shouldn’t ever create a noticeable delay, except right after system boot.
0 Responses
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.