Generate, check and validate codes