2.1.0 • Published 2 years ago

xcaesar v2.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

xcaesar

The implementation of the Caesar Cipher in TypeScript

Installation

npm install xcaesar

Usage

import { XCaesar } from 'xcaesar';

const ceaserCipher = XCaesar({ shift: 5 });

const originalMessage = 'Hello, world! It is me!';
console.log('Original Message: ' + originalMessage);

const encryptedMessage = ceaserCipher.encrypt(originalMessage);
console.log('Encrypted Message: ' + encryptedMessage);

const decryptedMessage = ceaserCipher.decrypt(encryptedMessage);
console.log('Decrypted Message: ' + decryptedMessage);

Api

interface XCaesarOptions {
    shift: number
    alphabet?: string // default is abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
}

interface XCaesar {
    encrypt: (plainText: string) => string
    decrypt: (cipherText: string) => string
    shift: number
    alphabet: {
        original: string
        shifted: string
    }
}