+ hashed = algorithms[algorithm](hashed.encode("utf-8")).digest()
+ # TODO: remove this exception trap after the switch to py2k
+ try:
+ hashed = "".join(format(x, "02x") for x in bytes(hashed))
+ except ValueError:
+ hashed = "".join(format(ord(x), "02x") for x in bytes(hashed))