Skip to content

Instantly share code, notes, and snippets.

@leeorf
Last active May 25, 2022 03:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leeorf/90b75dedfbd58c2c1af9eb5063f7790f to your computer and use it in GitHub Desktop.
Save leeorf/90b75dedfbd58c2c1af9eb5063f7790f to your computer and use it in GitHub Desktop.
SHA1 generator.
#!/usr/bin/env node
import crypto from "crypto";
import readlineSync from "readline-sync";
import clipboard from "clipboardy";
const main = () => {
const shasum = crypto.createHash("sha1");
const password = readlineSync.question("Password: ", {
hideEchoBack: true, // The typed text on screen is hidden by `*` (default).
});
shasum.update(password);
clipboard.writeSync(shasum.digest("hex"));
console.log("Hash copied to the clipboard!");
};
main();
{
"name": "sha1-generator",
"version": "1.0.0",
"main": "src/index.js",
"license": "Apache-2.0",
"scripts": {
"start": "node src/index.js",
"format": "prettier src/index.js --write"
},
"description": "A simple sha1 generator script",
"repository": "git@github.com:leeorf/sha1-generator.git",
"author": "Leo Rodrigues <leo.rf.dev@gmail.com>",
"dependencies": {
"clipboardy": "^3.0.0",
"readline-sync": "^1.4.10"
},
"type": "module",
"bin": {
"sha1-generator": "./index.js"
}
}

Why this?

This script was mainly made for the sake of having a way to retrieve a sha1 from a string without exposing the string that will be encrypted. I've done this because I rely on some sha1 hashes to access some files at work and I don't want to expose those strings and hashes when I'm in a video call or doing some pair programming

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment