Пример #1
0
        private async Task DecryptFile()
        {
            ImgAPI imgApi = await API
                            .GetImageDetail(txtIPServer.Text, listFiles.SelectedItem.ToString());

            //ImgDTO imgDto = new ImgDTO(
            //    listFiles.SelectedItem.ToString()
            //    , null
            //    , Encoding.ASCII.GetBytes(imgApi.imageByteArray));

            Byte[] bytes  = Encoding.ASCII.GetBytes(imgApi.imageByteArray);
            Bitmap bitmap = ConvertImg.ToBitMap(bytes);

            picBox.Image = bitmap;
        }
Пример #2
0
        private async Task DecryptFile()
        {
            ImgAPI imgApi = await API.GetImageDetail(txtIPServer.Text, listFiles.SelectedItem.ToString());

            if (imgApi != null)
            {
                Byte[] bytes = Convert.FromBase64String(imgApi.imageByteArray);
                //Desencripción:
                int      i = 0, j = 0;
                UInt32[] llave      = new UInt32[4];
                UInt32[] vectorinit = new UInt32[4];
                foreach (char x in txtKey.Text)
                {
                    llave[i] = UInt32.Parse(x.ToString());
                    i++;
                }

                foreach (char x in txtIV.Text)
                {
                    vectorinit[j] = UInt32.Parse(x.ToString());
                    j++;
                }
                Encrypt desencriptar = new Encrypt(llave, vectorinit);
                desencriptar.inicializacion();
                desencriptar.generateKeyStream((bytes.Length) / 4);

                Byte[] plaintext = desencriptar.generateCiphertext(bytes);

                Bitmap bitmap = ConvertImg.ToBitMap(plaintext);

                if (bitmap != null)
                {
                    picBox.Image = bitmap;
                }
                else
                {
                    ShowMessage("Error al desencriptar la imagen.", true);
                }
            }
            else
            {
                ShowMessage("Error al conectarse con el servidor.", true);
            }
        }
Пример #3
0
        private async Task Upload(string nameFile, Byte[] bytes)
        {
            string stringImg = Convert.ToBase64String(bytes);
            ImgAPI imgAPI    = new ImgAPI
            {
                imageName      = nameFile,
                imageByteArray = stringImg
            };

            bool postSuccess = await API.PostImage(txtIPServer.Text, imgAPI);

            if (postSuccess)
            {
                ShowMessage("Imagen encriptada y subida exitosamente..");
            }
            else
            {
                ShowMessage("Error al conectarse con el servidor.", true);
            }
        }
Пример #4
0
        private async Task Upload(string nameFile, Byte[] bytes)
        {
            string stringImg = Encoding.ASCII.GetString(bytes);
            ImgAPI imgAPI    = new ImgAPI
            {
                imageName      = nameFile,
                imageByteArray = stringImg
            };

            //List<string> list = await API.GetImageName(txtIPServer.Text);

            ImgAPI imgapi = await API.GetImageDetail(txtIPServer.Text, "gatito.jpg");

            string caption = "HC-128";
            string message = "Imagen encriptada exitosamente. OK\n";

            //message += stringImg + "\n";
            //message += String.Join("\n",list) + "\n";
            //message += imgapi.imageName + "\n";
            //message += imgapi.imageByteArray + "\n";

            MessageBox.Show(this, message, caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
        }