bdauvergne / python-oath

Python implementation of HOTP, TOTP and OCRA algorithms from OATH
BSD 3-Clause "New" or "Revised" License
128 stars 35 forks source link

Fix hotp hex format for longs. #11

Closed dainnilsson closed 10 years ago

dainnilsson commented 10 years ago

One of the hotp tests is currently failing, due to hex() returning a string ending in "L" whenever a long is passed to it. This fixes that.

dainnilsson commented 10 years ago

I'm not sure why this test is failing on my machine and not on Travis, but here's the failure without this patch:

FAIL: test_accept_hotp (tests.hotp.Hotp)

Traceback (most recent call last): File "/mnt/sdb1/personal/python-oath/tests/hotp.py", line 43, in test_accept_hotp self.assertEqual(h, hexa) AssertionError: '4c93cf18L' != '4c93cf18'

dainnilsson commented 10 years ago

Sorry to spam, but I think I found out that the reason it's failing on my machine and not on Travis. I think the conversion to long happens on 32-bit systems, which causes hex to append the "L" suffix. Under 64-bit ints are 64 bits, and the conversion is avoided.

bdauvergne commented 10 years ago

Great I take it.