Refactor encoding in Hasher