Ejemplo n.º 1
0
 private void func_rc5_getwrb()
 {
     try
     {
         rc5_encode = new encode(int.Parse(ComboBox_rc5_W.Text), int.Parse(textBox_rc5_R.Text));
         for (int i = 0; i < textBox_rc5_password.Text.Length; i++)
         {
             if (i != rc5_encode.w)
             {
                 int.Parse(textBox_rc5_password.Text[i].ToString());
             }
         }
         if (rc5_encode.w != 16 && rc5_encode.w != 32 && rc5_encode.w != 64)
         {
             throw new Exception();
         }
         if (textBox_rc5_password.Text.Length > rc5_encode.w && textBox_rc5_password.Text[rc5_encode.w] != ' ')
         {
             string temp_s = textBox_rc5_password.Text.Substring(rc5_encode.w);
             textBox_rc5_password.Text = textBox_rc5_password.Text.Substring(0, rc5_encode.w) + " " + temp_s;
             textBox_rc5_password.SelectionStart = textBox_rc5_password.TextLength;
         }
         if (textBox_rc5_password.Text.Length != rc5_encode.w * 2 + 1)
         {
             if (textBox_rc5_password.Text.Length != rc5_encode.w * 2)
                 throw new Exception();
             if (textBox_rc5_password.Text.Contains(' '))
                 throw new Exception();
         }
         rc5_encode.keyword = textBox_rc5_keyword.Text;
         rc5_encode.password = textBox_rc5_password.Text.Replace(" ", "");
         if (rc5_encode.keyword == null || rc5_encode.password == null)
         {
             throw new Exception();
         }
     }
     catch
     {
         label_rc5_encodeOut.Text = "";
         return;
     }
     rc5_encode.readyencode();
     label_rc5_encodeOut.Text = rc5_encode.getencode();
 }
Ejemplo n.º 2
0
 private void button_rc5_getPassword_Click(object sender, EventArgs e)
 {
     if (textBox_rc5_encodeIn.TextLength <= 3 || textBox_rc5_encodeIn.TextLength > 60)
     {
         label_password.Text = "";
         wrongTip_rc5_encodeInError.Show();
         return;
     }
     if (textBox_rc5_encodeIn.Text[0] == ' ' || textBox_rc5_encodeIn.Text[textBox_rc5_encodeIn.TextLength - 1] == ' ')
     {
         label_password.Text = "";
         wrongTip_rc5_encodeInError.Show();
         return;
     }
     if (!textBox_rc5_encodeIn.Text.Contains(" "))
     {
         label_password.Text = "";
         wrongTip_rc5_encodeInError.Show();
         return;
     }
     try
     {
         rc5_encode = new encode(int.Parse(ComboBox_rc5_W.Text), int.Parse(textBox_rc5_R.Text));
         if (rc5_encode.w != 16 && rc5_encode.w != 32 && rc5_encode.w != 64)
         {
             throw new Exception();
         }
         rc5_encode.keyword = textBox_rc5_keyword.Text;
         rc5_encode.password = textBox_rc5_encodeIn.Text;
         if (rc5_encode.keyword == null)
         {
             throw new Exception();
         }
     }
     catch
     {
         return;
     }
     rc5_encode.readyencode();
     label_password.Text = rc5_encode.recode();
 }