My SHA1 code was returning a different hex digest when I ran it on my Telit GM862 GPS. I eventually tracked the problem down to the hex() function. I found that hex(3181490320L) did not return the right result on my device!
Run this test script and post your results below.
My output was:
Edit: In case anyone’s interested here’s my hex() replacement. It’s probably much slower, but it works and can pad the hex string to x bytes.