I am new to PHP but have been programming in VB6 for many years. I have the following code I'm trying to convert to PHP and I've figured most of it out but am stuck on one line that I can't find an equivalent way to do in PHP (it is a VERY simple encryption scheme I know but I cannot change it). My plan is for a webform to supply the Username and callsign but for testing purposes, I'm assigning those variables.
Here's the VB6 code:
Username = "Peter Piper"
CallSign = "aa4aa"
CallSign = UCase(CallSign) 'force uppercase callsign
If Len(Username) Then
For A = 1 To Len(CallSign)
B = Asc(Mid(CallSign, A, 1))
B = B + Asc(Mid(Username, (A Mod Len(Username)) + 1, 1))
strBuff = strBuff & Chr$(B And &HFF)
Next
Else
strBuff = CallSign
End If
And here's what I've come up with (so far) in PHP:
$username = "Peter Piper;
$callsign = "aa4aa" ;
$upperCase = strtoupper($callsign) ;
$callsign = $upperCase ;
$datalen = strlen($username) ;
//Encrypt string
If($datalen > 0) {
For($A=1; $A<=$datalen; $A++)
{
$B = substr($callsign, $A, 1) ; // get one character at a time
$B = ord($B) ; // convert to ASCII
}
}
Thanks in advance