Ver Mensaje Individual
  #2 (permalink)  
Antiguo 19/05/2011, 07:23
Avatar de Aquaventus
Aquaventus
 
Fecha de Ingreso: junio-2010
Ubicación: Lima-Peru , En el alba de la naturaleza
Mensajes: 2.105
Antigüedad: 13 años, 10 meses
Puntos: 267
Respuesta: Encriptación ficheros .config

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 original
  1. Public Sub encriptar()
  2.  
  3.             Dim Directorio As String = Context.Parameters.Item("targetdir").ToString & "\GRYPHOS.exe"
  4.             Dim provider As String = "DataProtectionConfigurationProvider"
  5.             Dim configuration As System.Configuration.Configuration = Nothing
  6.             Dim section As ConnectionStringsSection = Nothing
  7.  
  8.             Try
  9.                 configuration = ConfigurationManager.OpenExeConfiguration(Directorio)
  10.  
  11.                 If configuration IsNot Nothing Then
  12.  
  13.                     Dim changed As Boolean = False
  14.                     section = TryCast(configuration.GetSection("connectionStrings"), ConnectionStringsSection)
  15.  
  16.                     If section IsNot Nothing Then
  17.                         If (Not (section.ElementInformation.IsLocked)) And (Not (section.SectionInformation.IsLocked)) Then
  18.                             If Not (section.SectionInformation.IsProtected) Then
  19.                                 changed = True
  20.                                 ' Encrypt the section.
  21.                                 section.SectionInformation.ProtectSection(provider)
  22.                             End If
  23.                         End If
  24.                         If changed Then
  25.                             ' Indicates whether the associated configuration section will be saved even if it has not been modified.
  26.                             section.SectionInformation.ForceSave = True
  27.  
  28.                             ' Save the current configuration.
  29.                             configuration.Save()
  30.                         End If
  31.                     End If
  32.                 End If
  33.  
  34.             Catch ex As Exception
  35.                 MsgBox(ex.Message)
  36.             End Try
  37.  
  38.         End Sub
__________________
Internet es tener todo el conocimiento global a tu disposición.
Desarrollo de Software - Ejemplos .Net