Location: PHPKode > projects > Esvon Personals > esvon-personals/inc/funcs/rc4_encrypt.php
<?php

function rc4_encrypt ($pwd, $data){

  $key[] = '';
  $box[] = '';

  $pwd = substr(md5($pwd),0,10);

  $pwd_length = strlen($pwd);
  $data_length = strlen($data);

  for ($i = 0; $i < 256; $i++)
  {
    $key[$i] = ord($pwd[$i % $pwd_length]);
    $box[$i] = $i;
  }

  for ($j = $i = 0; $i < 256; $i++)
  {
    $j = ($j + $box[$i] + $key[$i]) % 256;
    $box[$i] ^= $box[$j];
    $box[$j] ^= $box[$i];
    $box[$i] ^= $box[$j];
  }

  for ($a = $j = $i = 0; $i < $data_length; $i++)
  {
    $a = ($a + 1) % 256;
    $j = ($j + $box[$a]) % 256;

    $box[$a] ^= $box[$j];
    $box[$j] ^= $box[$a];
    $box[$a] ^= $box[$j];

    $k = $box[(($box[$a] + $box[$j]) % 256)];
    $cipher .= chr(ord($data[$i]) ^ $k);

  }

  return $cipher;

}


?>
Return current item: Esvon Personals