UNPKG

keygentoolshed

Version:

Key generation utilities for cryptographic operations. QUANTUM ENCRYPTION FOLDER UPDATE!!! See its folder for all <3

63 lines (54 loc) 1.68 kB
import fs from 'fs'; import zlib from 'zlib'; import path from 'path'; function compressData(input, type, outputPath) { let data; if (type === 'file') { data = fs.readFileSync(input); } else if (type === 'text' || type === 'key') { data = Buffer.from(input); } else { throw new Error('Invalid type specified. Use "file", "text", or "key".'); } const compressedData = zlib.gzipSync(data); if (outputPath) { fs.writeFileSync(outputPath, compressedData); console.log(`Compressed data saved to ${outputPath}`); } else { console.log(compressedData.toString('base64')); } } const args = process.argv.slice(2); let input = ''; let type = ''; let outputPath = ''; if (args.length === 0) { console.error('No arguments provided. Use --file or -f for file, --text or -t for text, --key or -k for key, and optionally --saveTo or -st for output file path.'); process.exit(1); } for (let i = 0; i < args.length; i++) { if (args[i] === '--file' || args[i] === '-f') { type = 'file'; input = args[i + 1]; } if (args[i] === '--text' || args[i] === '-t') { type = 'text'; input = args[i + 1]; } if (args[i] === '--key' || args[i] === '-k') { type = 'key'; input = args[i + 1]; } if (args[i] === '--saveTo' || args[i] === '-st') { outputPath = args[i + 1]; } } if (!input || !type) { console.error('Input and type must be specified. Use --file, --text, or --key.'); process.exit(1); } try { compressData(input, type, outputPath); } catch (error) { console.error('Failed to compress data:', error.message); }