Creating a wooden locking mechanism is not hard in case you can make use of a laser cutter. This instructable describes my approach for locking a compartment
Using online tools for constructing the rack and pinion is very handy. I've used one for calculating the number of teeth and all parameters, and another one to export DXF files in order to import into my CAD system for the laser cutter.
These are my favorites:
Finally you should end up with something like this plan
Let the cutter do it's job