Need help with generating (T)OTP in c++

Hi, I'm doing a project where i need to make a token security system. So i need a device that displays the 6 digit code, and one where you can insert it an can verify it.
Well the device for displaying i have already, made an arduino with rtc and lcd, so the otp must be time based.

Now, the problem which I can't fix is, On the arduino I'm using C, with the Sha1 library and codes. Generating a 6 digit code works with the time.

Now I need that to work on c++ to. I just need a CMOS environment (very simple) where I can insert the 6 digit code.

So basically I'm asking if anyone can help me with the code, including algorithm that can generate a 6 digit pin, and is time based.
Then i can use that program and also upload in the arduino, so we have the same algorithm and time both on the pc and the token device.

Could anyone help me out here? :)
If the code is based on the current time, it could be difficult to synchronize to different computers to have the same code. That's why random number generators use the time to get their numbers. It's almost impossible for two generators to get the same numbers, even if they are started at what you may think is the exact same second.

Regardless, you should take a look at <time.h> and <random>.
http://www.cplusplus.com/reference/ctime/
http://www.cplusplus.com/reference/random/
Hi, thanks for your reply.

The time is just from one pc. I use an RTC chip for the arduino bord, which syncs, and can be synced in the exact second as my own laptop. That part I already have, the only problem is that i need an algorithm for both parties to use that time to make a 6 digit token code out of it.
Topic archived. No new replies allowed.