Time sync between RTC module and remote computer

Subject says it all :slight_smile: but the problem is not so simple to solve.

I need to "generate" 4 digit code that will be the same on the PC and Arduino side.
To make this i bouth DS3231 module and start to make tests.

Now the funny part:

  • the idea was to take day, month and hour to get some basic code and then add some value to make this code, a bit "harder" to crack.
  • the code is for opening door on one external toilet, so no one will try to crack this code :slight_smile:
  • in the practical situation this should look like:
    20 / 01 /2016, 19:10:00 = 20 01 19 10 = 20011910 / 10000 = 2001 + some value = final code

On the arduino side
All reverse.

Now, the problems:

  • i will get 3 number codes each time when the day in month = 01,02,03 etc.
  • what will happen if PC generates more same codes or if some code will not be used in predefined time ( 3 hours ) etc. How can i make sync then...Did someone try to make such stuff ?

I don't understand how you create the value(s). The /10000 will cut off the time. leaving only the date.

What's the data type of the code? 4 digit int or 4 character string?