Re: Optimize simple file XOR code

From: Date: Thu, 24 Jun 2004 15:34:10 +0000
Subject: Re: Optimize simple file XOR code
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-188964@lists.php.net to get a copy of this message
Just to speed things up a little more... * Thus wrote Marcel Tschopp: > ... > $key = GenerateKey($hash); > $keylen = strlen($key = implode('', $key)); > > $handle = fopen($filename, 'r'); > while (!feof($handle)) > { > // Set the time limit or the script will time out > // on large files > set_time_limit(30); > > $data = fread($handle, 8192); // read in the $keylen amount $data = fread($handle, $keylen); > for ($i = 0; $i < strlen($data); $i = $i + $keylen) > { > $data = substr_replace($data, substr($data, $i, $keylen) ^ $key, $i, $keylen); > } > > // Return the encrypted version to the browser > echo $data; // then all the above becomes usless.. echo $data ^ $key Curt -- First, let me assure you that this is not one of those shady pyramid schemes you've been hearing about. No, sir. Our model is the trapezoid!

« previous php.general (#188964) next »