[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

<?
        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);

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

                $pData = "01" . $tCryptoText;
                }
                $theResult = base64_encode($pData);
                return $theResult;
        }


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;
$tClearText .= chr( ord($pData{$k}) ^ ord($tKeyString{$i}) );
$i++;
}

$pData = $tClearText;
break;

default:
exit ("ERROR: fwUnpack invalid encryption method = " . $tEncryptionMethod);
}

$theResult = gzinflate(substr($pData,10));

if ($theResult === FALSE)
exit ("ERROR: fwUnpack -- wrong password");
else
return $theResult;
}
?>


Le 2 mars 04, � 16:40, Frank Leahy a �crit :

Many, many thanks to shaosean and Brian Yennie for providing php versions of fwPack and fwUnpack. I cleaned them up a bit, added some error handling, and tested the final code.

I've put the final code up on my server at http://photoalbum.backtalk.com/code_snippets/fwPack_fwUnpack.php.txt

Richard, maybe you'd like to add this code to your fwPack/fwUnpack stack?

Thanks,
-- Frank
Weblog: http://cornwall.backtalk.com

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



Le 2 juil. 04, � 20:35, Chipp Walters a �crit :

Howdy,

Anyone out there have a copy of the php fwPack/unPack php scripts posted a while back? It turns out the server where it's hosted is down...

best,

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



Best to All,

--
Bien cordialement, Pierre Sahores

100, rue de Paris
F - 77140 Nemours

[EMAIL PROTECTED]

GSM:   +33 6 03 95 77 70
Pro:      +33 1 41 60 52 68
Dom:    +33 1 64 45 05 33
Fax:      +33 1 64 45 05 33

Inspection acad�mique de Seine-Saint-Denis
Applications et SGBD ACID SQL (WEB et PGI)
Penser et produire "delta de productivit�"

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

Reply via email to