[EMAIL PROTECTED] wrote:

well here are the two functions.. next ;-)

-Sean


A thing of beauty, Sean. Thank you.


--
 Richard Gaskin
 Fourth World Media Corporation
 ___________________________________________________________
 [EMAIL PROTECTED]       http://www.FourthWorld.com


<%


function fwPack($pData, $pPassword="") {
  if ($pPassword === ""):
    $pData = "00" . gzencode($pData);

  else:
    $tKeyString = pack("H*", md5($pPassword));
    $tKeyStringLen = strlen($tKeyString);

    $pData = gzencode($pData);
    $tDataLen = strlen($pData);

    $tCryptoText = "";
    $i = 0;
    for ($k=0; $k < $tDataLen; $k++):
      if ($i >= $tKeyStringLen):
        $i = 0;
      endif;
      $tCryptoText .= chr( ord($pData{$k}) ^ ord($tKeyString{$i}) );
      $i++;
    endfor;
    $pData = "01" . $tCryptoText;
  endif;
  return base64_encode($pData);
}
// end fwPack


function fwUnpack($pData, $pPassword="") {
$pData = base64_decode($pData);
$tEncryptionMethod = $pData{0} . $pData{1}; // get the encryption method
$pData = substr($pData,2); // remove the encryption method from the data


  switch($tEncryptionMethod):
  case "00":   // no encryption
    break;
  case "01":   // md5 encryption
    $tKeyString = pack("H*", md5($pPassword));
    $tKeyStringLen = strlen($tKeyString);

$tDataLen = strlen($pData);

    $tClearText = "";
    $i = 0;
    for ($k=0; $k < $tDataLen; $k++):
      if ($i >= $tKeyStringLen):
        $i = 0;
      endif;
      $tClearText .= chr( ord($pData{$k}) ^ ord($tKeyString{$i}) );
      $i++;
    endfor;
    $pData = $tClearText;
  endswitch;

return gzinflate(substr($pData,10)); }
// end fwUnpack



echo fwUnpack(fwPack("abraxas", "fred"), "fred");


%>

_______________________________________________
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to