public void TestEncryptionDefaultSettings() { var machine = new MyEnigmaMachine(); string cypher = machine.Encrypt("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); Assert.AreEqual("FUVEPUMWARVQKEFGHGDIJFMFXI", cypher); machine.ResetRotors(); cypher = machine.Encrypt("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); Assert.AreEqual("FUVEPUMWARVQKEFGHGDIJFMFXI", cypher); machine.ResetRotors(); cypher = machine.Encrypt("FUVEPUMWARVQKEFGHGDIJFMFXI"); Assert.AreEqual("ABCDEFGHIJKLMNOPQRSTUVWXYZ", cypher); }
public void TestEncryptionRingStartingLettertSettings() { var machine = new MyEnigmaMachine(); machine.SetCurrentRotorRingLetters(new[] { 'F', 'R', 'Q' }); string cypher = machine.Encrypt("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); Assert.AreEqual("MHHKTNIROWJNYMNWKHMVEZQHWU", cypher); machine.ResetRotors(); cypher = machine.Encrypt("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); Assert.AreEqual("MHHKTNIROWJNYMNWKHMVEZQHWU", cypher); machine.ResetRotors(); cypher = machine.Encrypt("MHHKTNIROWJNYMNWKHMVEZQHWU"); Assert.AreEqual("ABCDEFGHIJKLMNOPQRSTUVWXYZ", cypher); }
public void TestEncryptionRingOffsetSettings() { var machine = new MyEnigmaMachine(); machine.SetupRotors(new[] { new RotorInfo("I", 'A', 'B'), new RotorInfo("II", 'A', 'B'), new RotorInfo("III", 'A', 'B') }); string cypher = machine.Encrypt("AAAAA"); Assert.AreEqual("EWTYX", cypher); machine.ResetRotors(); cypher = machine.Encrypt("AAAAA"); Assert.AreEqual("EWTYX", cypher); machine.ResetRotors(); cypher = machine.Encrypt("EWTYX"); Assert.AreEqual("AAAAA", cypher); }
public void TestLowercaseEncryption() { var machine = new MyEnigmaMachine(); string cypher = machine.Encrypt("This is a test; Another test. Hello, World!"); Assert.AreEqual("Zpjj sv s pgbw; Wwiukog fxym. Lprfq, Zpvkw!", cypher); }
public void TestNonCharEncryption() { var machine = new MyEnigmaMachine(); string cypher = machine.Encrypt("THIS IS A TEST; ANOTHER TEST. HELLO, WORLD!"); Assert.AreEqual("ZPJJ SV S PGBW; WWIUKOG FXYM. LPRFQ, ZPVKW!", cypher); }
public void TestFullParameters() { var machine = new MyEnigmaMachine(); machine.SetupRotors(new[] { new RotorInfo("IV", 'M', 'F'), new RotorInfo("V", 'C', 'U'), new RotorInfo("II", 'W', 'T') }); machine.SetupPlugboard("ABCKEFGHIJDLNMOPQRSTUZWXYV"); string cypher = machine.Encrypt("This is a test"); Assert.AreEqual("Rmxe li c wmua", cypher); }