A fully worked example, with all the program....
Two LEDs, two switches, an electromechanical strikeplate.
(The project could be expanded to use more LEDs, more switches without any hard work. That would make the system more secure.)
Anyone wanting to go past the electronic lock looks at the pattern of "ons/ offs" on the LEDs, applies a simple rule, and presses the "secret code" on the switches, and the door opens. (Or, more precisely, the electronic strikeplate is activated, and the door it is on can be pushed open.)
(Other pages discuss the development programme leading up to the solution in tutorial form.)