Categories
JavaScript Answers

How to create random-salt-hash with crypto with Node.js and JavaScript?

Spread the love

Sometimes, we want to create random-salt-hash with crypto with Node.js and JavaScript.

In this article, we’ll look at how to create random-salt-hash with crypto with Node.js and JavaScript.

How to create random-salt-hash with crypto with Node.js and JavaScript?

To create random-salt-hash with crypto with Node.js and JavaScript, we can use the crypto.randomBytes method.

For instance, we write:

const crypto = require('crypto')
const buf = crypto.randomBytes(16);
console.log(buf)

We call crypto.randomBytes with 16 to create a buffer object with 16 random bytes.

Conclusion

To create random-salt-hash with crypto with Node.js and JavaScript, we can use the crypto.randomBytes method.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *