private void btnKriptujFile_Click(object sender, EventArgs e) { if (fileForCryptPath.Equals("")) { MessageBox.Show("File isn't selected!", "Missing file!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } byte[] file = null; file = File.ReadAllBytes(fileForCryptPath); byte[] cryptedFile = algorithm.Crypt(file); File.WriteAllBytes(@".\\Crypted\\" + fileForCryptName + fileExtension, cryptedFile); if (checkCloud.Checked) { var cloudProxy = new CryptoServiceClient(); using (var stream = new FileStream(@".\\Crypted\\" + fileForCryptName + fileExtension, FileMode.Open, FileAccess.Read)) { bool resultOfUpload = cloudProxy.UploadFile(fileForCryptName + fileExtension, stream); if (resultOfUpload == true) { MessageBox.Show("File uploaded to cloud!", "Successfull upload!", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("There was error while trying to upload file!", "Error while uploading!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } cloudProxy.Close(); } }
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; }