Fixed hashing function sometimes returning wrong hex string