30 private grid: Record<string, string> = {};
35 private inverse: Record<string, string> = {};
49 for (let r = 1; r <= 5; r++) {
50 for (let c = 1; c <= 5; c++) {
51 const ch = letters[idx++];
52 const key = `${r}${c}`;
54 this.inverse[key] = ch;
66 encode(plainText:
string =
""): string {
70 const up = ch.toUpperCase();
72 return this.grid[
'I'];
74 if (/[A-Z]/.test(up)) {
75 return this.grid[up] ?? ch;
89 decode(cipherText:
string =
""):
string {
92 .map(tok => this.inverse[tok] ?? tok)
Abstract base class providing common functionality for cipher implementations.
static readonly ALPHABET
Standard English alphabet for cipher operations.
Implementation of the Polybius Square substitution cipher.
constructor()
Constructor for Polybius Square cipher.
readonly CipherName
Identifier name for this cipher.
export const Record< string,(...args:any[])=> string