Imagine this: You place a borrowed finger ring, bracelet, or glass into the lock and it is examined to ensure that it is shut. The magician never touches the lock again. Spectators can try all sorts of random numbers, but they will be unable to guess the 4-digit code to unlock the latch.
Finally, you say "Put in the year in which you were born" or "Put in the year of your anniversary". None of these numbers are known to you before you approach your spectator! However, upon entering their birth year as the four digits - boom - it is the code to unlocking this mysterious lock.
With enough creativity, you can make any personal information be the code that unlocks this magical lock: Birth year, anniversary year, pin code, etc.