25 abstract encode(plaintext:
string, key?: any):
string;
33 abstract decode(ciphertext:
string, key?: any):
string;
44 static readonly
ALPHABET:
string =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
52 protected sanitize(text:
string):
string {
53 return text.toUpperCase().replace(/[^A-Z]/g,
'');
63 protected mod(n: number, m: number): number {
64 return ((n % m) + m) % m;
75 protected modInverse(a: number, m: number): number {
77 for (let x = 1; x < m; x++) {
78 if (this.mod(a * x, m) === 1) {
82 throw new Error(
"No modular inverse");
92 protected shiftChar(ch:
string, shift: number):
string {
93 const i =
BaseCipher.ALPHABET.indexOf(ch.toUpperCase());
abstract abstract encode(plaintext:string, key?:any) abstract decode(ciphertext:string, key?:any) readonly CipherName
Abstract method to encode plaintext.