37 encode(plaintext:
string, key:
string):
string {
38 const sanitizedKey = this.sanitize(key);
40 throw new Error(
"Key required");
49 if (plainIndex === -1) {
54 sanitizedKey[keyIndex % sanitizedKey.length]
59 this.mod(plainIndex + shift, 26)
74 decode(ciphertext:
string, key:
string):
string {
75 const sanitizedKey = this.sanitize(key);
77 throw new Error(
"Key required");
86 if (cipherIndex === -1) {
91 sanitizedKey[keyIndex % sanitizedKey.length]
96 this.mod(cipherIndex - shift, 26)