private void btnstarttext_Click(object sender, EventArgs e) { int textchar = 0; char toconvert = 'a'; foreach (char character in txbinputtext.Text) { //Get character from string, change it to an int. //put int trough encryption //output text in txboutputtext textchar = Convert.ToByte(character) - 64; int longoutput = new Enigmahardware(savedrotor).Encrypt(rotorchoice, rotorvalue, rotoroffset, textchar - 1) + 65; toconvert = Convert.ToChar(longoutput); txboutputtext.Text += toconvert.ToString(); int lableI = savedrotor[0] + 65; output = Convert.ToChar(lableI); lblcurrentI.Text = Convert.ToString(output); int lableII = savedrotor[1] + 65; output = Convert.ToChar(lableII); lblcurrentII.Text = Convert.ToString(output); int lableIII = savedrotor[2] + 65; output = Convert.ToChar(lableIII); lblcurrentIII.Text = Convert.ToString(output); int lableIV = savedrotor[3] + 65; output = Convert.ToChar(lableIV); lblcurrentIV.Text = Convert.ToString(output); } }
private void Liveinput_TextChanged(object sender, EventArgs e) { //Takes the input from the textfield (any single character value) // if a - z capitalize // if A - Z make A 1, B 2 and so on // if any other character ignore. (no error, just ignore) // clear the text field...? char halfway; char.TryParse(Liveinput.Text.ToUpper(), out halfway); try { //should this be 65? if not why? This will never be 0(if using letters) // See livecode -1 livecode = Convert.ToByte(halfway - 64); } // IS PROBLEM (See rotor advance) catch (Exception exception) { } //for testing //MessageBox.Show(livecode.ToString()); //send all variables to class enigmahardware after input of single letter //Add 65 to get an ascii value //and return value to txbcurrentout int test = new Enigmahardware(savedrotor).Encrypt(rotorchoice, rotorvalue, rotoroffset, livecode - 1) + 65; output = Convert.ToChar(test); txbcurrentout.Text = Convert.ToString(output); int lableI = savedrotor[0] + 65; output = Convert.ToChar(lableI); lblcurrentI.Text = Convert.ToString(output); int lableII = savedrotor[1] + 65; output = Convert.ToChar(lableII); lblcurrentII.Text = Convert.ToString(output); int lableIII = savedrotor[2] + 65; output = Convert.ToChar(lableIII); lblcurrentIII.Text = Convert.ToString(output); int lableIV = savedrotor[3] + 65; output = Convert.ToChar(lableIV); lblcurrentIV.Text = Convert.ToString(output); }