private void ConfigMachine(SZ42 machine) { string[] positions, patterns; int i = 0; positions = settings.Positions; patterns = settings.Patterns; foreach (Wheel wheel in machine.ChiWheels) { wheel.CurrentPosition = Convert.ToInt32(positions[i]); wheel.Pattern = patterns[i].ToCharArray(); i++; } foreach (Wheel wheel in machine.PsiWheels) { wheel.CurrentPosition = Convert.ToInt32(positions[i]); wheel.Pattern = patterns[i].ToCharArray(); i++; } foreach (Wheel wheel in machine.MuWheels) { wheel.CurrentPosition = Convert.ToInt32(positions[i]); wheel.Pattern = patterns[i].ToCharArray(); i++; } }
public void Execute() { Progress(0.0, 1.0); if (first) { ConfigMachine(reset); first = false; } isPlayMode = true; if (!string.IsNullOrEmpty(inputString)) { if (settings.Action == 0) { Lorenz_LogMessage("encrypting", NotificationLevel.Info); sz42Encrypt = ResetMachine(); Encrypt(); } else if (settings.Action == 1) { Lorenz_LogMessage("decrypting", NotificationLevel.Info); sz42Decrypt = ResetMachine(); Decrypt(); } OnPropertyChanged("OutputString"); } Progress(1.0, 1.0); }
public Lorenz() { settings = new LorenzSettings(); reset = new SZ42(); //ConfigMachine(reset); settings.ReExecute += Lorenz_ReExecute; }
private SZ42 ResetMachine() { ms = new MemoryStream(); bf = new BinaryFormatter(); bf.Serialize(ms, reset); ms.Position = 0; SZ42 sz42 = (SZ42)bf.Deserialize(ms); ms.Close(); return(sz42); }