Implement real hashing function