Java Integer.ParseInt translation to python

John Machin sjmachin at lexicon.net
Wed Feb 9 07:05:08 EST 2005


jose isaias cabrera wrote:
> > the question is, how can I make this java (byte) call in python? so
that the
> result would be the right one, "[B at 1616c7"
>

Let's get this straight: you have 40 hex digits; both your Java code
and your Python code each do 20 iterations, printing the 20 bytes that
you have composed.
They print the same bytes; the Java code is printing the 3rd column as
a signed 8-bit integer; some Python code (*NOT*, as Nick has pointed
out, the code that you posted) is printing the actual byte (in some
encoding or other).

However some Java code (I can't believe that it was the Java code that
you posted) has printed NINE bytes which bear no relation that I can
see to any of the TWENTY bytes that the posted Java code should have
stowed in retBuf.

You claim that "[B at 1616c7" is the right answer -- what is the question?
What is it meant to be? Your routine is called PrepareHash; is it
possible that you are seeing these 9 bytes _after_ hashing? Funny
hashing scheme; they usually give 4, 8, 16, etc bytes, but worth an ask
...




More information about the Python-list mailing list