Using some electronic component, a numeric keypad, a CMOS integrated circuit, three transistors and optocoupler can be made a simple electronic lock.
Closure is achieved by a cascade of analog switches, each connected by a matrix of programmable keys. If line A is connected to key 2, line B to key 9 and line C to key 5 key and 2 is pressed, ES1 closes and remains closed due to current what is received trough R7. If pressed then key 9, ES2 closes and remains closed (because ES1 is already closed). Now all you need do is to press 5, after which ES3closes, thus activating the optocoupler, whose transistor begins to conduct.
Unused key code ABC must to be connected all to the line D. When one of these keys is pressed by mistake or ignorance, D line switches ES4 to a logic "1" (which is maintained by R6) and T1 result, causing complete deactivation of the circuit, in fact, even if ES1 is again driven by associated press, it will not latching, as long as T1 is conducting. To restart first turn the S1 button, so to ES4 open and lock T1. T2 is connected in parallel with the reset circuit and controlled by #. Key * can be used as an ordinary button ring powering relay through transistor T3 and order Re as ring transformer.