Encode IDs