Page 1 of 1

License key for C program?

Posted: Mon Jan 21, 2019 4:56 pm
by Killertechno
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.

Re: License key for C program?

Posted: Mon Jan 21, 2019 6:22 pm
by topguy
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.