You can use the VIN number to get your car key code if you contact your dealership, according to Masterlocksmith.com. In order to receive the code, you must have proof of registration and ownership, the car must be less than 10 years old, and it must have the original locks.
Dealerships often rekey previously used vehicles before placing them on the market, according to Masterlocksmith.com. They also clear their database after 10 years to make room for newer vehicles. Note that some newer vehicles use transponder technology and require a corresponding transponder code in addition to the car key code when making a new key.