Something akin to a bag's combination lock? So set a code before exiting cockpit, and use it for re-entry? That's a good idea me thinks, worth considering. Perhaps it can hold 2 or 3 combinations current & any 1 can be used once for re-entry (to cater for an augmented crew)
Just have to sort out what happens if a pilot outside the cockpit is held at knife-point. Would he/she refuse to divulge or relent?