keygentoolshed
Version:
Key generation utilities for cryptographic operations. QUANTUM ENCRYPTION FOLDER UPDATE!!! See its folder for all <3
42 lines (36 loc) • 1.15 kB
JavaScript
import fs from 'fs';
import path from 'path';
function saveKey(filePath, key) {
try {
const resolvedPath = path.resolve(filePath);
fs.writeFileSync(resolvedPath, key);
console.log(`Key saved successfully to ${resolvedPath}`);
} catch (error) {
console.error('Error saving key:', error.message);
throw error;
}
}
const args = process.argv.slice(2);
let filePath = '';
let key = '';
if (args.length === 0) {
console.error('No arguments provided. Use --filePath or -fp followed by the file path and --key or -k followed by the key.');
process.exit(1);
}
for (let i = 0; i < args.length; i++) {
if (args[i] === '--filePath' || args[i] === '-fp') {
filePath = args[i + 1];
}
if (args[i] === '--key' || args[i] === '-k') {
key = args[i + 1];
}
}
if (!filePath || !key) {
console.error('Both file path and key must be specified. Use --filePath or -fp followed by the file path and --key or -k followed by the key.');
process.exit(1);
}
try {
saveKey(filePath, key);
} catch (error) {
console.error('Failed to save key:', error.message);
}