Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2003
    Posts
    16

    Arrow Unanswered: special chars, alpabets and numbers

    all chars a to z and special chars and numbers

    i suppose iam using the RC4. I took this algo from this forums i suppose. iam posting the algo.
    function encrypt($d,$action,$p=$~!#(')
    { $ivcl= 10;
    $N = 1;
    static $randset = 0;
    if($action == "d-1")
    { $k = substr($d, 0, $ivcl);
    $d = substr($d, $ivcl);
    }
    elseif($action == "d-2" || $action =="d-3")
    { $d = base64_decode($d);
    $k = substr($d, 0, $ivcl);
    $d = substr($d, $ivcl);
    }
    elseif($action == "e-1" || $action == "e-2" || $action == "e-3")
    { $k="";
    if($ivcl>0)
    { while(strlen($k)<$ivcl)
    { switch(mt_rand(1,3))
    {
    case 1:
    $k.=chr(mt_rand(48,57));
    break;
    case 2:
    $k.=chr(mt_rand(65,90));
    break;
    case 3:
    $k.=chr(mt_rand(97,122));
    break;
    }
    }
    }
    }
    if($action == "e-3")
    { $d = serialize($d);
    }

    $p .= $k;

    for ($i=0; $i < 255; $i++)
    $S[$i] = $i;

    $j = 0;
    $t = strlen($p);

    for ($i=0; $i < 255; $i++)
    { $K[$i] = ord(substr($p,$j,1));
    $j = ($j + 1) % $t;
    }

    $j=0;
    for ($kk=0; $kk < $N; $kk++)
    { for ($i = 0; $i < 255; $i++)
    { $j = ($j + $S[$i] + $K[$i]) & 0xff;
    $t = $S[$i];
    $S[$i] = $S[$j];
    $S[$j] = $t;
    }
    }

    $i=0;
    $j=0;
    $ii=0;
    $ret = '';

    $dlen = strlen($d);
    for ($ii=0; $ii < $dlen; $ii++)
    { $c=$d{$ii};
    $i = ($i + 1) & 0xff;
    $j = ($j + $S[$i]) & 0xff;
    $t = $S[$i];
    $S[$i] = $S[$j];
    $S[$j] = $t;
    $t = ($S[$i] + $S[$j]) & 0xff;
    $ret .= chr($S[$t]) ^ $c;
    }
    if($action == "d-1" || $action == "d-2")
    { return $ret;
    }
    elseif($action == "d-3")
    { $ret = unserialize(stripslashes($ret));
    return $ret;
    }
    elseif($action == "e-1")
    { return $k .= $ret;
    }
    elseif($action == "e-2" || $action == "e-3")
    { return base64_encode($k .= $ret);
    }
    }

  2. #2
    Join Date
    Mar 2003
    Posts
    16
    i am sorry its reply to a post. i mislead to the new topic

Posting Permissions

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