public FormA51() { InitializeComponent(); algorithm = new A51Algorithm(); }
private void btnKriptuj_Click(object sender, EventArgs e) { byte[] x, y, z; int[] sx, sy, sz; x = new byte[19]; y = new byte[22]; z = new byte[23]; byte vx, vy, vz; char[] tempx = txtX.Text.ToCharArray(); char[] tempy = txtY.Text.ToCharArray(); char[] tempz = txtZ.Text.ToCharArray(); string[] tempsx = txtStepX.Text.Split(' '); string[] tempsy = txtStepY.Text.Split(' '); string[] tempsz = txtStepZ.Text.Split(' '); vx = byte.Parse(txtVoteX.Text); vy = byte.Parse(txtVoteY.Text); vz = byte.Parse(txtVoteZ.Text); sx = new int[tempsx.Length]; sy = new int[tempsy.Length]; sz = new int[tempsz.Length]; for (int i = 0; i < 19; i++) { x[i] = byte.Parse(tempx[i].ToString()); } for (int i = 0; i < 22; i++) { y[i] = byte.Parse(tempy[i].ToString()); } for (int i = 0; i < 23; i++) { z[i] = byte.Parse(tempz[i].ToString()); } for (int i = 0; i < tempsx.Length - 1; i++) { sx[i] = int.Parse(tempsx[i]); } for (int i = 0; i < tempsy.Length - 1; i++) { sy[i] = int.Parse(tempsy[i]); } for (int i = 0; i < tempsz.Length - 1; i++) { sz[i] = int.Parse(tempsz[i]); } char[] tempUlaz = txtUlaz.Text.ToCharArray(); byte[] ulaz = new byte[tempUlaz.Length]; for (int i = 0; i < tempUlaz.Length; i++) { ulaz[i] = byte.Parse(tempUlaz[i].ToString()); } A51Algorithm a = new A51Algorithm(x, y, z, vx, vy, vz, sx, sy, sz); byte[] izlaz = a.Crypt(ulaz); char[] tempIzlaz = new char[ulaz.Length]; string strU = ""; for (int i = 0; i < ulaz.Length; i++) { tempIzlaz[i] = char.Parse(izlaz[i].ToString()); strU += tempIzlaz[i].ToString(); } textBox1.Text = strU; }
private void btnRandom_Click(object sender, EventArgs e) { A51Algorithm a = new A51Algorithm(); byte[] X, Y, Z; int votingX, votingY, votingZ; int[] stepX, stepY, stepZ; X = new byte[19]; Y = new byte[22]; Z = new byte[23]; stepX = new int[2]; stepY = new int[2]; stepZ = new int[2]; for (int i = 0; i < 19; i++) { X[i] = byte.Parse((i % 2).ToString()); Y[i] = byte.Parse((2 * i % 2).ToString()); Z[i] = byte.Parse((3 * i % 2).ToString()); } Y[19] = 0; Y[20] = 1; Y[21] = 1; Z[19] = 1; Z[20] = 1; Z[21] = 1; Z[22] = 0; votingX = 9; votingY = 9; votingZ = 9; stepX[0] = 4; stepX[1] = 11; stepY[0] = 7; stepY[1] = 17; stepZ[0] = 5; stepZ[1] = 19; char[] tempx = new char[19]; string strX = ""; for (int i = 0; i < 19; i++) { tempx[i] = char.Parse(X[i].ToString()); strX += tempx[i].ToString(); } txtX.Text = strX; char[] tempy = new char[22]; string strY = ""; for (int i = 0; i < 22; i++) { tempy[i] = char.Parse(Y[i].ToString()); strY += tempy[i].ToString(); } txtY.Text = strY; char[] tempz = new char[23]; string strZ = ""; for (int i = 0; i < 23; i++) { tempz[i] = char.Parse(Z[i].ToString()); strZ += tempz[i].ToString(); } txtZ.Text = strZ; txtVoteX.Text = votingX.ToString(); txtVoteY.Text = votingY.ToString(); txtVoteZ.Text = votingZ.ToString(); for (int i = 0; i < stepX.Length; i++) { txtStepX.Text += stepX[i].ToString() + " "; } for (int i = 0; i < stepY.Length; i++) { txtStepY.Text += stepY[i].ToString() + " "; } for (int i = 0; i < stepZ.Length; i++) { txtStepZ.Text += stepZ[i].ToString() + " "; } }