Asper Header  1.0.14
The header injector extension
Loading...
Searching...
No Matches
ciphers.ts
Go to the documentation of this file.
1
22
23import { BaseCipher } from "./base/baseCipher";
24
33export class Cipher {
38 private cipherMap: Record<string, BaseCipher> = {};
39
46 const cipherClasses = [
78 ];
79
80 for (const CipherClass of cipherClasses) {
81 const instance = new CipherClass();
82 // Lowercase the key for case-insensitive lookup
83 this.cipherMap[this.normalize(instance.CipherName)] = instance;
84 }
85 }
86
94 private normalize(name: string): string {
95 return name.toLowerCase().replace(/\s+/g, '');
96 }
97
108 encode(plaintext: string, key?: any, cipherName?: string): string {
109 if (!cipherName) {
110 throw new Error("Cipher name required");
111 }
112 const cipher = this.cipherMap[this.normalize(cipherName)];
113 if (!cipher) {
114 throw new Error(`Cipher "${cipherName}" not found`);
115 }
116 return cipher.encode(plaintext, key);
117 }
118
129 decode(ciphertext: string, key?: any, cipherName?: string): string {
130 if (!cipherName) {
131 throw new Error("Cipher name required");
132 }
133 const cipher = this.cipherMap[this.normalize(cipherName)];
134 if (!cipher) {
135 throw new Error(`Cipher "${cipherName}" not found`);
136 }
137 return cipher.decode(ciphertext, key);
138 }
139
146 listCiphers(): string[] {
147 return Object.keys(this.cipherMap);
148 }
149}
150
export const ALLCiphers
Comprehensive object containing all cipher classes and utilities.
Definition ciphers.ts:158
Implementation of Base64 encoding and decoding.
Definition base64.ts:21
Abstract base class providing common functionality for cipher implementations.
Definition baseCipher.ts:18
Central cipher management class providing unified access to all cipher implementations.
Definition ciphers.ts:33
constructor()
Constructor initializing all available cipher implementations.
Definition ciphers.ts:45
Implementation of XOR (Exclusive OR) encryption/decryption.
Definition xor.ts:22
BaudotCipher
Definition index.ts:18
CaesarCipher
Definition index.ts:19
PortaCipher
Definition index.ts:22
ColumnarCipher
Definition index.ts:19
FractionatedMorseCipher
Definition index.ts:20
BaconCipher
Definition index.ts:18
EnigmaCipher
Definition index.ts:20
GronsfeldCipher
Definition index.ts:20
MonoalphabeticCipher
Definition index.ts:21
VigenereCipher
Definition index.ts:23
VICCipher
Definition index.ts:23
ADFGVXCipher
Definition index.ts:17
Cipher
Definition index.ts:28
BeaufortCipher
Definition index.ts:18
TrifidCipher
Definition index.ts:23
AffineCipher
Definition index.ts:17
Base64Cipher
Definition index.ts:18
MorseBasicCipher
Definition index.ts:21
ScytaleCipher
Definition index.ts:23
AutokeyCipher
Definition index.ts:17
PolybiusCipher
Definition index.ts:22
RailFenceCipher
Definition index.ts:22
TapCodeCipher
Definition index.ts:23
PigpenCipher
Definition index.ts:21
KeywordCipher
Definition index.ts:20
BifidCipher
Definition index.ts:19
RouteCipher
Definition index.ts:22
DoubleTranspositionCipher
Definition index.ts:19
AtbashCipher
Definition index.ts:17
NihilistCipher
Definition index.ts:21
ROT13Cipher
Definition index.ts:22
const instance
Singleton logger instance for application-wide use.
Definition logger.ts:870
export const Record< string,(...args:any[])=> string