Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Python int to hex string

Name: Anonymous 2007-12-24 2:58

class crc32calc:
    def __init__(self): self.value = 0
    def update(self, data): self.value = zlib.crc32(data, self.value)
    def digest(self): return self.value
    def hexdigest(self): return '%08x' % self.value

Trying to get result of crc32 sum in hex. '%08x', however, sometimes returns a negative value (negative sign followed by seven hex digits). How can I get the right value?

Name: Anonymous 2007-12-24 4:04

print '%u %08x' % (self.value, self.value)

prints -145952065 -8b30d41
I'm looking for 4149015231 f74cf2bf
I assume self.value is being treated as a signed int. How do I get the unsigned value?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List