How to use public encryption to manage licensing o

2019-04-02 06:30发布

问题:

I don't want to publish my app on Android Market, but i would create a license key from my website based on the MAC address of the user device. It should include also expiration date. Once the user enters the code in the android device it should be recognised. I've read that it can be done by using custom public encryption. In this scenario i should implement:

  1. A function in my application that takes the MAC address of the device and shows a string to the user.
  2. A function on my website that owns the private key and cipher the string at point 1. and adds expiration date
  3. A function in my application that decipher the string at point 2. using the puplic key and validates the license key.

I've read many discussions on stackoverflow and other sites but nothing applicable... or it is not clear how to apply in my scenario :(

Can you provide me e way to solve this problem? is there something that is android native that i'm missing (i hope) ?

Many thanks! Marco

回答1:

I see nothing really difficult to implement your intents:

  1. Your licensing server must have its own private and public key pairs.
  2. Then you have to create private key in your application during 1st run/install. It can be done just randomly
  3. Then you have to interchange between your application and server with public keys
  4. During buying/licensing procedure your application should encrypt MAC address or other (gmail id, IMEI code whatever) send to server - server stores key
  5. In order to check validity of license application sends to server cipher of MAC - server checks it against stored in database

If you don't know how to implement private/public keys stuff - read manuals, there're a lot of implementations of Diffie-Hellman's procedure - it's easy and nothing special there



回答2:

I was looking to implement licensing on apps that are not distributed through Play and came across this:

https://code.google.com/p/droidactivator/

Maybe it will help you too?