Example #1
0
        private String Desepcritar(String contraseña)
        {
            string[] vlEnEncrypt = contraseña.Split('/');


            string[] vlEncode = vlEnEncrypt[0].Split(',');
            string[] vlKey    = vlEnEncrypt[1].Split(',');
            string[] vlIV     = vlEnEncrypt[2].Split(',');

            //Creamos las variables byte[] y le creamos el tamaño
            byte[] vlByEncode = new byte[vlEncode.Length];
            byte[] vlByKey    = new byte[vlKey.Length];
            byte[] vlByIV     = new byte[vlIV.Length];

            //Variable int que almacena la cantidad de item del array
            int vlConEncode = vlEncode.Length - 1;

            //Recorremos el string[] y le pasamos el valor al byte[]
            for (int i = 0; i <= vlConEncode; i++)
            {
                vlByEncode[i] = byte.Parse(vlEncode[i]);
            }

            //Variable int que almacena la cantidad de item del array
            int vlConKey = vlKey.Length - 1;

            //Recorremos el string[] y le pasamos el valor al byte[]
            for (int i = 0; i <= vlConKey; i++)
            {
                vlByKey[i] = byte.Parse(vlKey[i]);
            }

            //Variable int que almacena la cantidad de item del array
            int vlConIV = vlEncode.Length - 1;

            //Recorremos el string[] y le pasamos el valor al byte[]
            for (int i = 0; i <= vlConIV; i++)
            {
                vlByIV[i] = byte.Parse(vlIV[i]);
            }

            //Mandamos a desencriptar el texto
            string vlValue = RijndaelEncrypt.Decode(vlByEncode, vlByKey, vlByIV).ToString();

            return(vlValue);
        }
Example #2
0
        private String ecriptar(String contraseña)
        {
            //Texto a encriptar
            vlTexto = contraseña;

            //Mandamos a encriptar el texto, nos retorna el la encriptacion junto con las claves
            vlEncriptado = RijndaelEncrypt.Encode(vlTexto).ToString();

            string[] vlEnEncrypt = vlEncriptado.Split('/');

            string[] vlEncode = vlEnEncrypt[0].Split(',');

            foreach (string value in vlEncode)
            {
                vlTextoEncriptado = vlTextoEncriptado + value;
            }
            return(vlEncriptado);
        }