UNPKG

crypto-keygen-suite

Version:

Key generation utilities for cryptographic operations. YES I RENAMED IT OMG BASES AND PROTOCOLS!!! See its folder for all <3

27 lines (22 loc) 822 B
import crypto from 'crypto' function generateCamelliaKey(length) { if (![128, 192, 256].includes(length)) { throw new Error("Key length must be 128, 192, or 256 bits."); } // Generate a random key of the specified length const key = crypto.randomBytes(length / 8); // Convert bits to bytes return key; } // Main function to handle user input function main() { const args = process.argv.slice(2); // Get command-line arguments const length = parseInt(args[0], 10); // Convert the first argument to an integer try { const key = generateCamelliaKey(length); console.log(`Generated Camellia key (${length} bits, base64):`, key.toString('utf-8')); // Output in base64 } catch (error) { console.error(error.message); } } // Run the main function main();