xor incongruences
Peter Otten
__peter__ at web.de
Thu Oct 16 17:16:53 EDT 2008
Michele wrote:
> Hi,
> I write a simple encoder in python and Java; they do the same
> computations, with the same inputs: however they won't produce the same
> output.
> Let me explain with code.
>
> First of all, you need a test file for input:
> $ dd if=/dev/urandom of=test.img bs=1048576 count=1
>
> I have attached the code.
> As you can see we have xor-red the same inputs (bitlists are the same,
> thus the selected blocks to xor are the same - you can easily see it,
> whenever a block is xor-red both programs will print out its hash).
> But here comes the strange: the random_block that the
> create_random_block function returns is not the same: in Java this block
> has an hash which is different from the Python one.
> Why?
> random_block = ['0']*blocksize
should be
random_block = ['\0']*blocksize
As John Machin already told you in another thread -- the character "0" is
not the same as the 0-byte "\0".
Peter
More information about the Python-list
mailing list