Re: Encryption & Decryption script
- From: Michael Fesser <netizen@xxxxxx>
- Date: Tue, 30 Sep 2008 18:12:36 +0200
..oO(Willem Bogaerts)
I get bored last night and wrote a script that uses xor for encrypt-
decrypt, however it woks fine under linux 2.6.25, text and documents
are ok, but fails on compressed files *.jpg, *.pdf , etc . I didn't
test script on windows.
I did not look at the code, but xor on PHP is quite counter-intuitive.
The most significant bit is seen as a sign bit and is treated special.
Can you elaborate on that or give an example?
<?php
$foo = 129; // 10000001b
$bar = 66; // 01000010b
$huh = 200; // 11001000b
var_dump(decbin($foo ^ $bar)); // 11000011b
var_dump(decbin($foo ^ $huh)); // 01001001b
var_dump(decbin($bar ^ $huh)); // 10001010b
var_dump(decbin($foo ^ $bar ^ $huh)); // 00001011b
?>
All as expected.
Micha
.
- References:
- Encryption & Decryption script
- From: Betikci Boris
- Re: Encryption & Decryption script
- From: Willem Bogaerts
- Encryption & Decryption script
- Prev by Date: Re: Encryption & Decryption script
- Next by Date: Re: Array file I/O
- Previous by thread: Re: Encryption & Decryption script
- Next by thread: Re: Encryption & Decryption script
- Index(es):
Relevant Pages
|