/// <summary> /// Set the position of this rotor. /// This may trigger a rotation (if you choose to implement it!). /// </summary> /// <param name="ch"></param> /// <returns>True if the notch has been passed.</returns> public bool SetPosition(char ch) { if (!CHARACTERS.Contains(ch)) { throw new EnigmaRulesException("Invalid character to set position."); } int i = CHARACTERS.IndexOf(ch); bool rollover = false; while (Offset != i) { rollover = rollover || this.Increment(); } return(rollover); }
/// <summary> /// Get the Encyphered character from the input pass through this rotor. /// </summary> /// <param name="ch"></param> /// <returns></returns> public char In(char ch) { int i = (CHARACTERS.IndexOf(ch) + Offset) % 26; return(Mapping[i]); }
public char Reflect(char ch) { int i = CHARACTERS.IndexOf(ch); return(Mapping[i]); }