The Strategy: Shifting the Cipher
Define a family of algorithms, encapsulate each one, and make them interchangeable.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Strategy
ARCANUM SCHOOL: Illusion // Obfuscation
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
public interface GNOMEArtifice.EncryptionProtocol : Object {
public abstract void encrypt(string data);
}
public class GNOMEArtifice.QuantumCipher : Object, EncryptionProtocol {
public void encrypt(string data) {
print(@"Applying Quantum Cipher to: $(data)\n");
}
}
public class GNOMEArtifice.PolyalphabeticShift : Object, EncryptionProtocol {
public void encrypt(string data) {
print(@"Applying Polyalphabetic Shift to: $(data)\n");
}
}
public class GNOMEArtifice.DataUplink : Object {
private EncryptionProtocol protocol;
public void set_protocol(EncryptionProtocol protocol) {
this.protocol = protocol;
}
public void transmit(string data) {
this.protocol.encrypt(data);
print("Data transmitted to orbit.\n");
}
}
The hunters in the digital wastes constantly adapt, breaking codes as fast as you cast them. The Strategy pattern lets your Data Uplink alter its obfuscation magic on the fly. Rather than hardcoding a single cipher into the transmission array, you slot in an EncryptionProtocol. When one is compromised, you instantly swap the Quantum Cipher for a Polyalphabetic Shift without tearing down the connection, staying one step ahead of the ICE.
Runic Tags:
#Vala
#GObject
#Behavioral
#Strategy