Skip to content

Instantly share code, notes, and snippets.

@gabalafou
Last active July 30, 2021 04:30
Show Gist options
  • Save gabalafou/0fe4f144bcfb37c4b2ef156a428e8652 to your computer and use it in GitHub Desktop.
Save gabalafou/0fe4f144bcfb37c4b2ef156a428e8652 to your computer and use it in GitHub Desktop.
NodeJS: Generating a hard-to-guess password using a master password via HMAC-SHA1
const crypto = require("crypto");
const masterPassword = "opensesame";
const siteTag = "google.com";
const generatedPassword = crypto.createHmac("sha1", masterPassword).update(siteTag).digest("base64");
console.log(generatedPassword);
// Expected result: lr+ErV3uFsDPkep/Th7Xqva8Z4M=
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment