UNPKG

keygentoolshed

Version:

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

34 lines (29 loc) 983 B
import yargs from 'yargs/yargs'; import { hideBin } from 'yargs/helpers'; function atbashCipher(message) { const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; const reversedAlphabet = alphabet.split('').reverse().join(''); const result = []; for (const char of message) { if (char.match(/[a-z]/i)) { const isUpperCase = char === char.toUpperCase(); const index = alphabet.indexOf(char.toUpperCase()); const newChar = reversedAlphabet[index]; result.push(isUpperCase ? newChar : newChar.toLowerCase()); } else { result.push(char); } } return result.join(''); } const argv = yargs(hideBin(process.argv)) .option('message', { alias: 'm', description: 'The message to encrypt or decrypt', type: 'string', demandOption: true }) .help() .argv; const result = atbashCipher(argv.message); console.log('Result:', result);