private void btnThamMa_Click(object sender, EventArgs e) { txtMHBanMa.Text = txtMHBanMa.Text.Trim(); if (txtMHBanMa.Text == "") { MessageBox.Show("Bản mã đang trống", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } txtBanGiaiMa.Text = Hill.decrypt(txtMHBanMa.Text, "VJHACFCAVMUQBEQNDBPSKCDBIBWJAENNDYYGBEKWXXYOZAPMEVCFRJEWOMAN", "THEFREQUENCYOFLETTERSATTHEBEGINNINGSOFWORDSISDIFFERENTAGAINA"); }
private void btnGiaiMa_Click(object sender, EventArgs e) { txtMHBanMa.Text = txtMHBanMa.Text.Trim(); if (txtMHBanMa.Text == "") { MessageBox.Show("Bản mã đang trống", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } /// Kiểm tra khóa int k = (int)numRowCount.Value; Matrix mt = new Matrix(k, k); /// tính lại mt foreach (var item in panelGroupKhoa.Controls) { TextBox z = item as TextBox; Point pos = (Point)z.Tag; if (pos.X > k || pos.Y > k) { continue; } int gt = 0; try { gt = Int32.Parse(z.Text); } catch { gt = 0; } mt[pos.X, pos.Y] = new Complex(gt); } if (!MaHoa.Crypto.Hill.ok(mt)) { MessageBox.Show("Key chưa thỏa mãn. Không tồn tại ma trận nghịch đảo", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } txtBanGiaiMa.Text = Hill.decrypt(txtMHBanMa.Text, mt); }