Exemple #1
0
        private void btnKript_Click(object sender, EventArgs e)
        {
            RSAAlgorithm r    = new RSAAlgorithm(UInt32.Parse(txtP.Text), UInt32.Parse(txtQ.Text), UInt32.Parse(txtE.Text));
            int          ulaz = int.Parse(txtUlaz.Text);

            byte[] izlaz = r.Crypt(BitConverter.GetBytes(ulaz));
            uint   cr    = BitConverter.ToUInt32(izlaz, 0);

            txtKript.Text = cr.ToString();
        }
Exemple #2
0
        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();
            }
        }