Hola
juanleonardo, para encriptar tu config usa esto :
Código vb:
Ver originalPublic Sub encriptar()
Dim Directorio As String = "C:\RUTA DE TU ARCHIVO\MI_EXE.exe"
Dim provider As String = "DataProtectionConfigurationProvider"
Dim configuration As System.Configuration.Configuration = Nothing
Dim section As ConnectionStringsSection = Nothing
Try
configuration = ConfigurationManager.OpenExeConfiguration(Directorio)
If configuration IsNot Nothing Then
Dim changed As Boolean = False
section = TryCast(configuration.GetSection("connectionStrings"), ConnectionStringsSection)
If section IsNot Nothing Then
If (Not (section.ElementInformation.IsLocked)) And (Not (section.SectionInformation.IsLocked)) Then
If Not (section.SectionInformation.IsProtected) Then
changed = True
' Encrypt the section.
section.SectionInformation.ProtectSection(provider)
End If
End If
If changed Then
' Indicates whether the associated configuration section will be saved even if it has not been modified.
section.SectionInformation.ForceSave = True
' Save the current configuration.
configuration.Save()
End If
End If
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Y para leer desencriptado(Pero no revela tus datos encriptados en el config) por ejemplo :
Código C:
Ver originalpublic class Conexion
{
Configuration configuration = null;
ConnectionStringsSection section = null;
public String GetConex()
{
try
{
configuration = ConfigurationManager.OpenExeConfiguration(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase.ToString()).Remove(0, 6) + "\\MI_EXE.exe");
section = configuration.GetSection("connectionStrings") as ConnectionStringsSection;
section.SectionInformation.UnprotectSection();
section.SectionInformation.ForceSave = true;
return section.ConnectionStrings["cn1"].ConnectionString;
//return ConfigurationManager.ConnectionStrings["cn1"].ConnectionString;
}
catch (Exception ex)
{
return ex.Message;
}
}
}
Pero sería recomendable que lo encriptaras en un custom action en el setup del aplicativo.
Saludos!

.
PDT: Disculpa por ponerte en ambos lenguajes jajaja pero es que era lo unico que tenia a la mano.