31 private map: Record<string, string> = {
32 'A':
'.-',
'B':
'-...',
'C':
'-.-.',
'D':
'-..',
33 'E':
'.',
'F':
'..-.',
'G':
'--.',
'H':
'....',
34 'I':
'..',
'J':
'.---',
'K':
'-.-',
'L':
'.-..',
35 'M':
'--',
'N':
'-.',
'O':
'---',
'P':
'.--.',
36 'Q':
'--.-',
'R':
'.-.',
'S':
'...',
'T':
'-',
37 'U':
'..-',
'V':
'...-',
'W':
'.--',
'X':
'-..-',
38 'Y':
'-.--',
'Z':
'--..',
39 '0':
'-----',
'1':
'.----',
'2':
'..---',
'3':
'...--',
40 '4':
'....-',
'5':
'.....',
'6':
'-....',
'7':
'--...',
41 '8':
'---..',
'9':
'----.'
51 encode(plainText:
string =
""): string {
54 .map(c => this.map[c.toUpperCase()] ?? c)
65 decode(cipherText:
string =
""):
string {
67 for (
const key in this.map) {
68 inverseMap[this.map[key]] = key;
73 .map(code => inverseMap[code] ?? code)