keygentoolshed
Version:
Key generation utilities for cryptographic operations. QUANTUM ENCRYPTION FOLDER UPDATE!!! See its folder for all <3
34 lines (31 loc) • 1.02 kB
JavaScript
const crypto = require('crypto');
const yargs = require('yargs');
function generateHash(input, mode, bits) {
const hash = crypto.createHash(mode).update(input);
return bits ? hash.digest().slice(0, bits / 8) : hash.digest(); // Adjust output based on bits
}
const argv = yargs
.option('mode', {
alias: 'm',
description: 'Hashing mode (sha1, sha256, sha512)',
type: 'string',
default: 'sha256'
})
.option('bits', {
alias: 'b',
description: 'Bit length for the hash output (e.g., 256, 512)',
type: 'number',
default: 256
})
.option('input', {
alias: 'i',
description: 'Input string to hash',
type: 'string',
demandOption: true
})
.argv;
const inputString = argv.input;
const hashMode = argv.mode;
const bitLength = argv.bits;
const hashKey = generateHash(inputString, hashMode, bitLength);
console.log(`Raw Hash (${hashMode.toUpperCase()}):`, hashKey);