PHP Code:
function mid ($str, $start, $howManyCharsToRetrieve = 0)
{
$start--;
if ($howManyCharsToRetrieve === 0)
$howManyCharsToRetrieve = strlen ($str) - $start;
return substr ($str, $start, $howManyCharsToRetrieve);
}
function EncryptText($strText, $strKey) {
$i = 0;
$c = 0;
$strbuff = '';
if (strlen($strKey) > 0) {
for ($i = 1; $i <= strlen($strText); $i++) {
$c = ord(mid($strText, $i, 1));
$c = $c + ord(mid($strText, (fmod($i, strlen($strKey))) + 1, 1));
$strbuff = $strbuff & chr($c And 0xFF);
}
} else {
$strbuff = $strText;
}
return $strbuff;
}
VB Code:
'|-------------------------------VB Version Private Function EncryptText(strText As String, ByVal strKEY As String) Dim i As Integer, c As Integer Dim strBuff As String If Len(strKEY) Then For i = 1 To Len(strText) c = Asc(Mid$(strText, i, 1)) c = c + Asc(Mid$(strKEY, (i Mod Len(strKEY)) + 1, 1)) strBuff = strBuff & Chr$(c And &HFF) Next i Else strBuff = strText End If EncryptText = strBuff End Function
I'm trying to convert the VB function to a PHP one, but can't seem to get the things inside the loop right. Anyone able to point me in the right direction?![]()




Reply With Quote