Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a licensing functionality to a java program? [closed]

I have made an application in java. Now I want to deliver it to several clients. I want that each client must purchase a serial key to use that software. Without that key, the software shouldn't be run just like other softwares in the market.

How can I do that?

I know that I can't protect it fully. I just want a simple serial key functionality so that it would be hard for non-technical persons and novice programmers to crack the security.

like image 730
Yatendra Avatar asked Jan 23 '23 02:01

Yatendra


2 Answers

There are off-the-shelf libraries available. (A quick Google search turned up a product called JLicense, for example.) But it's not difficult and also more flexible to implement your own mechanism. One simple approach would be to compute the SHA-1 hash of the customer name plus some hard-coded salt. Encode the result as alphanumeric characters and you've got yourself a license key. Now, when someone goes to install your product, ask for their customer name and the license key. Recompute the hash and compare it to the customer key the user gave you to authenticate the key.

That's just one simple example. There's all kinds of things you can do including encrypting some data and storing it in the key (e.g. an expiration date or subset of unlocked features). You can make it as simple or complicated as you like.

Bear in mind, though, that any solution you come up with can be reverse-engineered by someone with enough skill and motivation, unless you use some kind of distributed authentication system. This is arguably easier to achieve in Java than with native compiled languages like C or C++. Obfuscating the code can help.

like image 156
Rob H Avatar answered Jan 30 '23 01:01

Rob H


I've mentioned EasyLicencer (that provides a decent level of protection against reverse engineering) in a previous answer. You'll find some other options in the discussion. For an open source solution, have a look at TrueLicense Library Collection but it might require more work on your side.

like image 30
Pascal Thivent Avatar answered Jan 30 '23 01:01

Pascal Thivent