Ver Mensaje Individual
  #152 (permalink)  
Antiguo 17/06/2009, 19:10
Avatar de Keyenight
Keyenight
 
Fecha de Ingreso: febrero-2009
Ubicación: En la PC usando VB
Mensajes: 42
Antigüedad: 15 años, 2 meses
Puntos: 0
Respuesta: FAQ´S del foro de Net

Tema: Encriptación {WINDOWS FORM}
Pregunta: ¿Comó Encripto un String?
Respuesta: Puedes usar estas funciones que cree de encriptación muy efectivas y cortas aqui les dejo el codigo:

Función complementaria
Código vb:
Ver original
  1. Function Invert(ByVal value As String) As String
  2.         Dim i As Integer, _
  3.         value2 As String = value
  4.         value = Nothing
  5.         For i = value2.Length To 1 Step -1
  6.             value = value & Mid(value2, i, 1)
  7.         Next
  8.         value2 = Nothing
  9.         Return value
  10.     End Function

Encriptación ASCII
Código vb:
Ver original
  1. Function EncriptEx(ByVal text As String) As String
  2.         EncriptEx = New String(Nothing)
  3.         Dim Null As String = Nothing
  4.         For Each i As String In text
  5.             Select Case Asc(i)
  6.                 Case 10 To 99
  7.                     Null = "0"
  8.                 Case 100 To 255
  9.                     Null = Nothing
  10.             End Select
  11.             EncriptEx = EncriptEx & Null & Asc(i)
  12.         Next
  13.         Return Invert(EncriptEx)
  14.     End Function
  15.  
  16.     Function DencriptEx(ByVal text As String) As String
  17.         DencriptEx = New String(Nothing)
  18.         text = Invert(text)
  19.         For i As Long = 1 To Len(text) Step 3
  20.             DencriptEx = DencriptEx & Chr(Mid(text, i, 3))
  21.         Next
  22.         Return DencriptEx
  23.     End Function

Encriptación ASCII con HEXADECIMAL
Código vb:
Ver original
  1. Function Encript(ByVal text As String) As String
  2.         Encript = Nothing
  3.         For Each i As String In text
  4.             Encript = Encript & Hex(CInt(Asc(i) & "0"))
  5.         Next
  6.         Return Invert(Encript)
  7.     End Function
  8.  
  9.     Function Dencript(ByVal text As String) As String
  10.         Dim ik As Long
  11.         text = Invert(text)
  12.         Dencript = Nothing
  13.         For i As Integer = 1 To text.Length Step 3
  14.             ik = CInt("&H" & Mid(text, i, 3))
  15.             If ik > 255 Then
  16.                 ik = ik / 10
  17.             End If
  18.             Dencript = Dencript & Chr(ik)
  19.         Next
  20.         Return Dencript
  21.     End Function

Espero que les haya sido de utilidad...

Última edición por Keyenight; 17/06/2009 a las 19:20