It doesn’t have just one secret code to your car. That’d be too easy for someone to electronically intercept, copy and use.
Instead, your car key uses what’s known as “rolling code.” Every time you press the button, a new, randomly generated code is sent over a radio frequency to your car, which has a synchronized code generator that recognizes it and then burns it so it can never be used again. The key and the car then create new codes for the next time around, and the process repeats. Read more: http://www.foxnews.com/leisure/2015/08/06/haker-rolljam-device-can-steal-your-car-keys-open-your-garage/?intcmp=hpbt1
Image courtesy of digidreamgrafix at FreeDigitalPhotos.net