Design and analysis of all-optical 4–2 binary encoder based on photonic crystal