Results 1 to 3 of 3

Thread: [Resolved]VB function to a PHP function

Threaded View

  1. #1

    Thread Starter
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765

    [Resolved]VB function to a PHP function

    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$i1));
      
    $c $c ord(mid($strText, (fmod($istrlen($strKey))) + 11));
      
      
    $strbuff $strbuff chr($c And 0xFF);

     }
    } else {
     
    $strbuff $strText;
    }


    return 
    $strbuff;

    VB Code:
    1. '|-------------------------------VB Version
    2. Private Function EncryptText(strText As String, ByVal strKEY As String)
    3.    Dim i As Integer, c As Integer
    4.    Dim strBuff As String
    5.    
    6.    If Len(strKEY) Then
    7.        For i = 1 To Len(strText)
    8.            c = Asc(Mid$(strText, i, 1))
    9.            c = c + Asc(Mid$(strKEY, (i Mod Len(strKEY)) + 1, 1))
    10.            strBuff = strBuff & Chr$(c And &HFF)
    11.        Next i
    12.    Else
    13.        strBuff = strText
    14.    End If
    15.    EncryptText = strBuff
    16. 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?
    Last edited by Pc_Madness; Dec 18th, 2003 at 02:59 AM.
    Don't Rate my posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width