views:

387

answers:

7

I'm making a simple licensing system for my apps.

I don't know about cryptography, but I know that I need a algorithm that consists of 2 keys: private and public.

I need to encrypt some data (expiration date and customer email) using my private key, and then my app will decrypt the data using the public key to compare expiration date.

Is there a known algorithm that does what I need?

EDIT:Problem solved. Helper class to use dsa avaliable Here

+4  A: 

Check out RSA. Most modern platforms will have implementations of RSA in their standard library.

Alvaro Rodriguez
A: 

Take a look at this article from codeproject.

Roger Ween
A: 

This isn't how private key encryption is supposed to work at all. You encrypt the data using the public key, it is only able to be decrypted using the private key.

edit: please ignore this I was completely wrong. I'll leave it in for other people who thunk like me to learn from

1800 INFORMATION
Nope, for signatures you encrypt with private and decrypt with public.
Liudvikas Bukys
with PGP it can go either way
Steven A. Lowe
With all public/private ciphers you encrypt with the private and decrypt with the public, and visa versa
roo
Well ok, you learn something new every day I guess
1800 INFORMATION
A: 

Sounds like you need a library!

I recommend checking out LibTomCrypt

Patrick_O
+4  A: 

What you want to do is actually called "signing" in the crypto world. You encrypt something with your private key, but since the public key is public, anyone can decrypt it. The algorithms that do this are called "asymmetric ciphers" (since the encryption key is different than the decryption key).

To be concrete, the RSA algorithm will do what you want in a secure way.

Do yourself a favour and do not try to implement it yourself; rather, take an existing implementation like the one from the OpenSSL library. It has an Apache-style license so you're probably allowed to use it in your application.

(However, note that such a licensing system is never completely secure: somebody can still modify your executable and remove the check. But clearly that is more effort than, say, simply modifying a registry value.)

Thomas
A: 

My answer to this question could be helpful. We use the rsa cipher mentioned to generate the signed licence.

roo
Thanks roo. By the way, i made this question after reading your answer. I needed to know the agorithm name. Now i know its rsa.
Gero
ha! glad to help :)
roo
A: 

Thanks for answers.
I have just finished a helper class to implement the licensing model that roo commented here.
If anyone find it util, it can be dowloaded here.

Gero