Making a electronic alphabet locker that lock gift to friends
You'd need a machine that walks from "locked, no entry" through "all letters so far right, at the Nth letter" to "unlocked" (or returns to the original state if any entered letter wasn't right for the position you are), with only pre-defined state transitions.

We call such a machine a finite state machine (FSM).

Your FSM is a relatively complex one, so it's a hassle to design in discrete logic.

It's, however, only a few lines of computer code. (Computers really are just very complex FSMs that we can make behave like any FSM.)

Thus, the logical and time-economical way forward here is learning how to use a microcontroller and how to write software for it; luckily, projects like Arduino make that both easy and relatively affordable.