Ver Mensaje Individual
  #2 (permalink)  
Antiguo 27/10/2009, 05:28
Avatar de Adler
Adler
Colaborador
 
Fecha de Ingreso: diciembre-2006
Mensajes: 4.671
Antigüedad: 18 años, 3 meses
Puntos: 126
Respuesta: Si he encriptado, ¿cómo desencripto?

Hola

Prueba con esta otra

Codificar

Código asp:
Ver original
  1. Dim Base64Chars
  2. Base64Chars ="Aa0Bb1Cc2Dd3Ee4Ff5Gg6Hh7IiJ8jKk9LlMmNnOoPpQqRrSsTtUuVvWwXxYyZz+/"
  3.                
  4. Public Function Codificar(byVal str)
  5. Dim c1, c2, c3, w1, w2, w3, w4, i, strIn, strOut
  6. strIn = Trim(str)
  7. For i = 1 To Len(strIn) Step 3
  8. c1 = Asc(Mid(strIn, i, 1))
  9. c2 = Asc(Mid(strIn, i + 1, 1) + Chr(0))
  10. c3 = Asc(Mid(strIn, i + 2, 1) + Chr(0))
  11. w1 = Int(c1 / 4) : w2 = (c1 And 3) * 16 + Int(c2 / 16)
  12. If Len(strIn) >= i + 1 Then
  13. w3 = (c2 And 15) * 4 + Int(c3 / 64)
  14. Else
  15. w3 = -1
  16. End If
  17. If Len(strIn) >= i + 2 Then
  18. w4 = c3 And 63
  19. Else
  20. w4 = -1
  21. End If
  22. strOut = strOut + aplCodificar(w1) + aplCodificar(w2) + aplCodificar(w3) + aplCodificar(w4)
  23. Next
  24. Codificar = strOut
  25. End Function
  26.  
  27. Private Function aplCodificar(byVal intIn)
  28. If intIn >= 0 Then
  29. aplCodificar = Mid(Base64Chars, intIn + 1, 1)
  30. Else
  31. aplCodificar = ""
  32. End If
  33. End Function

Descodificar

Código asp:
Ver original
  1. Public Function DeCodificar(byVal str)
  2. Dim w1, w2, w3, w4, i, strIn, strOut
  3. strIn = Trim(str)
  4. For i = 1 To Len(strIn) Step 4
  5. w1 = aplDeCodificar(Mid(strIn, i, 1))
  6. w2 = aplDeCodificar(Mid(strIn, i + 1, 1))
  7. w3 = aplDeCodificar(Mid(strIn, i + 2, 1))
  8. w4 = aplDeCodificar(Mid(strIn, i + 3, 1))
  9. If w2 >= 0 Then strOut = strOut + Chr(((w1 * 4 + Int(w2 / 16)) And 255))
  10. If w3 >= 0 Then strOut = strOut + Chr(((w2 * 16 + Int(w3 / 4)) And 255))
  11. If w4 >= 0 Then strOut = strOut + Chr(((w3 * 64 + w4) And 255))
  12. Next
  13. DeCodificar = strOut
  14. End Function
  15.  
  16. Private Function aplDeCodificar(byVal strIn)
  17. If Len(strIn) = 0 Then
  18. aplDeCodificar = -1 : Exit Function
  19. Else
  20. aplDeCodificar = InStr(Base64Chars, strIn) - 1
  21. End If
  22. End Function

Suerte
__________________
Los formularios se envían/validan con un botón Submit
<input type="submit" value="Enviar" style="background-color:#0B5795; font:bold 10px verdana; color:#FFF;" />