š¢ Node.js
š The different core modules
Crypto
The Crypto module (or more recently Web crypto which is the version with Web-compatible API) is a module that will allow you to perform a set of operations related to the world of cryptography.
Iām not particularly comfortable with all of this, but as developers we still have fairly frequent needs such as generating a SHA256 string or that kind of thing (for signing a file for example).
crypto.createHash("sha256").update("hello").digest("hex");
Obviously I do not recommend that you manage a password encryption yourself because it is very often the best way to do stupid things (use a lib like Argon2 instead). If you want to know why I recommend you go read the following article.
Personally, I also often use the crypto module to generate random values:
const crypto = require("crypto");
console.log(crypto.randomBytes(16).toString("hex"));
// 1a68967e44d1c1ad187f003ab95f3cd1
console.log(crypto.randomInt(100));
// 94
console.log(crypto.randomUUID());
// 7ea8c00a-cd01-442f-8011-56037e527b5f
ā¬ ļø š The different core modules: async_hooks | ā”ļø š¢ Node.js: š¦ npm package archive