Hola
egarcia1980ext aqui tengo un codigo que uso para encriptar al momento de generar el setup, Alli muestra como encripta una seccion del .config. Espero te sirva. Saludos!
.
Código VB.NET:
Ver originalPublic Sub encriptar()
Dim Directorio As String = Context.Parameters.Item("targetdir").ToString & "\GRYPHOS.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
End Try
End Sub