Beispiel #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;
        }
Beispiel #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);
            }
        }