private void btnRun_Click(object sender, EventArgs e) { try { SecurityEncryptor t = new SecurityEncryptor(); List<byte> Result = t.GetFiveByeteConstants(tbxOri.Text.Trim()); string Constractor = ""; if (Result.Count == 5) { for (int i = 0; i < 5; i++) { Constractor = Constractor + ByteToString(Result[i])+ " "; } } tbxResult.Text = Constractor.Trim(); tbxResult.Focus(); tbxResult.SelectAll(); } catch { MessageBox.Show("Security Constant NOT Generated", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnGetKey_Click(object sender, EventArgs e) { try { SecurityEncryptor t = new SecurityEncryptor(); //Generate Constant Byte List<byte> SecurityConstant = new List<byte>(); string[] Tmp = tbxResult.Text.Trim().Split(' '); if (Tmp.Length != 5) { throw new Exception("Please Enter The Right Security Constant"); } for (int i=0; i < 5; i++) { SecurityConstant.Add(Convert.ToByte(Tmp[i], 16)); } //Generate Seed List<byte> Seed = new List<byte>(); Tmp = tbxSeed.Text.Trim().Split(' '); if (Tmp.Length != 3) { throw new Exception("Please Enter The Right Seed"); } for (int i = 0; i < 3; i++) { Seed.Add(Convert.ToByte(Tmp[i], 16)); } //Generate Key List<byte> Key = t.GetKey(SecurityConstant, Seed); if (Key.Count != 3) { throw new Exception("Key Generate Failed"); } tbxKey.Text = ""; tbxKey.AppendText(ByteToString(Key[0]) + " "); tbxKey.AppendText(ByteToString(Key[1]) + " "); tbxKey.AppendText(ByteToString(Key[2])); tbxKey.Focus(); tbxKey.SelectAll(); } catch(Exception Error) { MessageBox.Show(Error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }