public static string EncriptarContrasenia(string pass) { string i = WebConfigurationManager.AppSettings["3DESIV"]; string k = WebConfigurationManager.AppSettings["3DESKey"]; TripleDESUtil crypto = new TripleDESUtil(i, k); byte[] contraseniaEncriptada = crypto.Encriptar(pass); string textoContraseniaEncriptada = string.Empty; foreach (byte item in contraseniaEncriptada) { if (textoContraseniaEncriptada == string.Empty) { textoContraseniaEncriptada += item.ToString(); } else { textoContraseniaEncriptada += "," + item.ToString(); } } string passEncry; passEncry = textoContraseniaEncriptada; return(passEncry); }
public static string DesencriptarContrasenia(string pass) { if (string.IsNullOrEmpty(pass) || pass == "null") { return(""); } else { string i = WebConfigurationManager.AppSettings["3DESIV"]; string k = WebConfigurationManager.AppSettings["3DESKey"]; TripleDESUtil descrypto = new TripleDESUtil(i, k); string contraseniaDesencriptada = descrypto.DesEncriptar(pass); return(contraseniaDesencriptada); } }