Exemple #1
0
 private void button3_Click(object sender, EventArgs e)
 {
     try
     {
         this.txtResult.Text  = string.Empty;
         this.txtResult.Text += "\nTexto Decifrado " + Cifrado.DescifradoTexto(this.textData.Text);
     }
     catch (Exception ex)
     {
         this.txtResult.Text = "Error :" + ex.Message;
     }
 }
Exemple #2
0
        private string PagarServicioJWT(RequestPagarServicios requestPagarServicios, string metodoApiGestoPago)
        {
            String result = string.Empty;
            _ResponsePagarServicios responsePagarServicios = new _ResponsePagarServicios();

            responsePagarServicios.request = ConexionAPI.ObtenerConexion() + requestPagarServicios.ObtenerParametros();

            string dataPost = JsonConvert.SerializeObject(requestPagarServicios);

            String cadenaNormal = Cifrado.CifradoTexto(dataPost);
            String cadenaEscape = Uri.EscapeDataString(Cifrado.CifradoTexto(dataPost));

            byte[] data = UTF8Encoding.UTF8.GetBytes("signed=" + cadenaEscape);
            new Logg().Info("strKey : " + ConexionAPI.secretKey + " | IV: " + ConexionAPI.IV);
            new Logg().Info("signed cadenaEscape =" + cadenaEscape);
            new Logg().Info("signed cadenaNormal =" + cadenaNormal);
            new Logg().Info("Descrypt: " + Cifrado.DescifradoTexto(cadenaNormal));
            string token = new Authenticate().GeneraToken();



            HttpWebRequest request = initRequest(data, metodoApiGestoPago);

            request.Headers.Add("Authorization", "Bearer " + token);
            Stream postStream = request.GetRequestStream();

            postStream.Write(data, 0, data.Length);

            HttpWebResponse response       = request.GetResponse() as HttpWebResponse;
            StreamReader    readerResponse = new StreamReader(response.GetResponseStream());

            result = readerResponse.ReadToEnd();
            Debug.WriteLine("Result ws: " + result);
            Debug.WriteLine("Json Params: " + JsonConvert.SerializeObject(requestPagarServicios));
            Debug.WriteLine("Data Cifrada: " + cadenaNormal);
            Debug.WriteLine("Data Cifrada Escape: " + cadenaEscape);
            Debug.WriteLine("token: " + token);
            return(result);
        }
Exemple #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                this.txtResult.Text = string.Empty;
                RequestPagarServicios requestPagarServicios = new RequestPagarServicios()
                {
                    IdProducto = 582, IdServicio = 133, Telefono = "4433740472", NumeroReferencia = "718931201466", Monto = 1243
                };
                //this.textData.Text = string.IsNullOrEmpty(this.textData.Text)

                this.textData.Text = JsonConvert.SerializeObject(requestPagarServicios);
                //this.txtResult.Text= Utilerias.CMVCifrarAES256(this.textData.Text);
                string texto = Cifrado.CifradoTexto(this.textData.Text);
                this.txtResult.Text = "Texto Cifrado " + texto;

                this.txtResult.Text += "\nTexto Decifrado " + Cifrado.DescifradoTexto(texto);
            }
            catch (Exception ex)
            {
                this.txtResult.Text = "Error :" + ex.Message;
            }
        }