private void btnKript_Click(object sender, EventArgs e) { string[] key = txtE.Text.Split(' '); int[] keyIn = new int[key.Length]; for (int i = 0; i < key.Length - 1; i++) { keyIn[i] = int.Parse(key[i]); } RC6Algorithm r = new RC6Algorithm(int.Parse(txtP.Text), int.Parse(txtQ.Text), keyIn); byte[] ulaz = new byte[16]; char[] ulazCh = txtUlaz.Text.ToCharArray(); for (int i = 0; i < ulaz.Length - 1; i++) { ulaz[i] = byte.Parse(ulazCh[i].ToString()); } byte[] izlaz = r.Crypt(ulaz); string[] izlazS = new string[izlaz.Length]; string izlazKraj = ""; for (int i = 0; i < izlaz.Length - 1; i++) { izlazS[i] = izlaz[i].ToString(); izlazKraj += izlazS[i] + " "; } txtKript.Text = izlazKraj; }
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(); } }