Programación php
Email: Password:


¡Regístrate gratis! | ¿Has perdido tu password?

Home
Blog

En él que podrás informarte de todas las noticias relacionadas con el posicionamiento de páginas web.

Ir al Blog de posicionamiento web



Foro de programación en PHP

Responder el mensaje

Convertir Codigo VB a PHP

Autor: Johnny Leyva
Publicado: 04-3-2008 09:27 AM
Necesito ayuda para convertir este código en Visual Basic a PHP.
Muchas Gracias de antemano.

Public Function Encriptar(vPassword As String) As String
If Len(vPassword) = 1 Then
Encriptar = Trim(Chr(ToDecimal(NotBinary(FORMAT(ToBinary(Asc(vPassword)), "00000000")))))
Else
If Len(vPassword) = 0 Then
Encriptar = ""
Else
Encriptar = Trim(Chr(ToDecimal(NotBinary(FORMAT(ToBinary(Asc(Mid(vPassword, 1, 1))), "00000000"))))) & Encriptar(Mid(vPassword, 2, Len(vPassword)))
End If
End If
End Function

Public Function ToBinary(vInteger As Integer) As String
If (vInteger \ 2) = 0 Then
ToBinary = Trim(Str(vInteger Mod 2))
Else
ToBinary = ToBinary(vInteger \ 2) & Trim(Str(vInteger Mod 2))
End If
End Function

Public Function ToDecimal(vBinary As String) As Integer
If Len(vBinary) = 1 Then
ToDecimal = vBinary
Else
ToDecimal = CInt(Mid(vBinary, 1, 1)) * (2 ^ (Len(vBinary) - 1)) + ToDecimal(Mid(vBinary, 2, Len(vBinary)))
End If
End Function

Public Function NotBinary(vBinary As String) As String
If Len(vBinary) = 1 Then
NotBinary = IIf(vBinary = "0", "1", "0")
Else
NotBinary = IIf(Mid(vBinary, 1, 1) = "0", "1", "0") & NotBinary(Mid(vBinary, 2, Len(vBinary)))
End If
End Function