43 encode(plainText:
string =
"", key:
string =
""):
string {
44 const cleanKey = this.sanitize(key);
45 const cleanText = this.sanitize(plainText);
46 const output:
string[] = [];
48 for (let i = 0; i < cleanText.length; i++) {
49 const ch = cleanText[i];
51 if (textIndex === -1) {
57 const cipherIndex = this.mod(keyIndex - textIndex, 26);
61 return output.join(
"");
72 decode(cipherText:
string =
"", key:
string =
""):
string {
74 return this.encode(cipherText, key);