Anyone done a rolling code key-lock?

Thread Starter


Joined Feb 11, 2008
Hi, I'm thinking of making a electronic key and lock, where the communication is one way only, ie; from key to lock. Probably InfraRed.

It is important the system cannot be broken by snooping. For instance if someone records a previous successful communication, and replays it, it will not open the lock a second time.

There are a number of ways this can be done with "rolling codes" where the code changes (increments) each time it is used, and previous codes become invalid.

One of the complications is that it would be nice to have more than 1 key device, ie for two different users. So the rolling code incrementation must not cause conflicts between multiple users.

If anyone has done a simple rolling code type implementation I would love to hear from you re how it worked, or potential issues etc. :)


Joined Mar 31, 2012
I think that, normally, multitransmitter systems simply maintain a separate state variable for each transmitter. However, they usually do this by comparing the received code against all state variables they are maintaining and activate if any of them match (since they don't know which transmitter is talking to them). Thus, if you have four transmitters, you have made it four times as easy for the bad guy to hit a valid code.

Also, my understanding is that most of the rolling code stuff out there doesn't use a long enough sequence or use sufficiently simple sequence generators that, given today's computing power, it is pretty easy to record a few sessions and then construct the sequence parameters to predict the next code. So be sure to consider that.


Joined Nov 23, 2012
Here is an application note from National.


Chip is from 1996 but the information of how the process works is good. The chip is able to do 2^48 codes across four devices in IR or RF.

I have a hand full of the chips from a collection of junk I once purchased. I have never found the need in any project so far but you never know. Send me a PM if you want to test a pair and give me feedback how they work.

Thread Starter


Joined Feb 11, 2008
Thanks guys! :)

Crutschow; I will read through that Atmel PDF, thanks for that.

WBahn; Yep I knew that many rolling codes are low security, that won't be an issue for me as I plan to use massive (matching) random keys inside the key and lock. So the rolling code is hashed with these massive keys, it will be virtually unbreakable as interception of a 64bit code (or many 64 bit codes) still can't lead to reverse deciphering an 8000 bit key.

Re the multiple users (multi key) what I had imagined is that the rolling code just contains an extra couple of bits to identify which user. That should not reduce security as it doesn't give a hacker more times the data (or less permutations).

GopherT; Thanks but I'm not really interested in dedicated chips, but more interested in general code or algorithm implementations. :)
I'd still like to hear specific suggestions, especially from
someone who has done a key->lock data application. :)