30 private mapping: Record<string, string>;
35 private inverse: Record<string, string>;
46 const sanitizedKeyword = this.sanitize(keyword);
47 const seen =
new Set<string>();
48 const keyAlphabet:
string[] = [];
51 for (
const ch of sanitizedKeyword) {
68 for (let i = 0; i < 26; i++) {
81 encode(plainText:
string =
""): string {
84 .map(c => this.mapping[c.toUpperCase()] ?? c)
95 decode(cipherText:
string =
""):
string {
98 .map(c => this.inverse[c.toUpperCase()] ?? c)
Abstract base class providing common functionality for cipher implementations.
static readonly ALPHABET
Standard English alphabet for cipher operations.
Implementation of the Keyword monoalphabetic substitution cipher.
readonly CipherName
Identifier name for this cipher.
constructor(keyword:string="")
Constructor for Keyword cipher.
export const Record< string,(...args:any[])=> string