public void TestLetterMappingsWithRotorOffsetSettings() { var socket = new RotorSocket(Rotor.Create("I", 'B')); Assert.AreEqual('K', socket.GetMappedLetter('A')); Assert.AreEqual('A', socket.GetMappedLetter('K', LetterMapper.MappingDirection.LeftToRight)); socket.Advance(); Assert.AreEqual('E', socket.GetMappedLetter('A')); Assert.AreEqual('A', socket.GetMappedLetter('E', LetterMapper.MappingDirection.LeftToRight)); }
public void TestLetterMappings() { var socket = new RotorSocket(Rotor.Create("I")); Assert.AreEqual('E', socket.GetMappedLetter('A')); Assert.AreEqual('A', socket.GetMappedLetter('E', LetterMapper.MappingDirection.LeftToRight)); //If for example rotor I is in the B-position, an A enters at the letter B //which is wired to the K. Because of the offset this K enters the next rotor in the J position. socket.Advance(); Assert.AreEqual('J', socket.GetMappedLetter('A')); Assert.AreEqual('A', socket.GetMappedLetter('J', LetterMapper.MappingDirection.LeftToRight)); }
private char GetCypherLetter(char key) { char mappedLetter = _plugboard.GetMappedLetter(key); mappedLetter = _fastRotor.GetMappedLetter(mappedLetter); mappedLetter = _middleRotor.GetMappedLetter(mappedLetter); mappedLetter = _slowRotor.GetMappedLetter(mappedLetter); mappedLetter = _reflector.GetMappedLetter(mappedLetter); mappedLetter = _slowRotor.GetMappedLetter(mappedLetter, MappingDirection.LeftToRight); mappedLetter = _middleRotor.GetMappedLetter(mappedLetter, MappingDirection.LeftToRight); mappedLetter = _fastRotor.GetMappedLetter(mappedLetter, MappingDirection.LeftToRight); mappedLetter = _plugboard.GetMappedLetter(mappedLetter, MappingDirection.LeftToRight); return(mappedLetter); }