Killertechno
Posts: 194
Joined: Wed Jan 02, 2013 8:28 am

License key for C program?

Mon Jan 21, 2019 4:56 pm

Hi to all,
I'm writing software in C for specific Raspberry HAT: I want software could work only with specific HAT (with specific unique hardware ID).
Is this possible in C?
I have no idea about doing this, it's first time...
Thanks.

User avatar
topguy
Posts: 6183
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: License key for C program?

Mon Jan 21, 2019 6:22 pm

Is this possible in C?
Depends totally on how "secure" you need it to be.

Simple idea:
You have a licensefile containing a string of numbers, your program reads this number and also reads the serialnumber of the HAT.
Then you can xor the one number with the other and if the result is another secret number only you (the program) know about then you know that the license match this hardware.

Is this secure, no, because if someone have a lot of HATs with sequential serialnumbers you will see a clear pattern in the licensekeys.
How to fix ? Use encryption or hashing algorithms, they will generate numbers that are indistinguishable from random data.

Now totally secure ? No, but unless your users are experts that can de-compile or run your program trough a debugger its probably safe enough.

Return to “C/C++”