Encode unicode for hashlib