Re: Optimize simple file XOR code
| From: | Curt Zirzow | Date: | Thu, 24 Jun 2004 15:41:24 +0000 |
| Subject: | Re: Optimize simple file XOR code | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-188965@lists.php.net to get a copy of this message | ||
* Thus wrote Marcus Johansson:
> Wow! That REALLY did make a great difference!
> Encoding a file of 2MB took 50 seconds before, now it is done in 1 (ONE)
> second!
>
> My Key is 8192 bytes long, is that the reason for why it so much faster
> for me?
Most likely because the number crunching is happening in C instead
of the php code.
> I don't really get how it works, but I guess I will figure it out.
It's taking advanatge to the xor'ing of strings:
echo 'hallo' ^ 'hello';
php will xor each corresponding byte in the string, so your output
will be (in binary)
04000
HTH,
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!