Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RSA algorithm library for Java [closed]

I want to provide my application with simple licensing mechanism based on RSA algorithm.

Are there any free RSA libraries?

like image 401
Roman Avatar asked Jan 08 '10 12:01

Roman


People also ask

Why is RSA not used anymore?

Whether it is as difficult as the factoring problem is an open question. There are no published methods to defeat the system if a large enough key is used. RSA is a relatively slow algorithm. Because of this, it is not commonly used to directly encrypt user data.

Has RSA ever been cracked?

It took 8 million core hours to crack RSA-240, and computing the discrete logarithm was even more time-intensive, taking 27 million core hours. The RSA keys most commonly used by ordinary computers today are larger in size, around 2048 bits, so the calculation isn't a threat to computer security.

What is the disadvantage of RSA algorithm?

Disadvantages of RSAIt may fail sometimes because for complete encryption both symmetric and asymmetric encryption is required and RSA uses asymmetric encryption only. It has slow data transfer rate due to large numbers involved. It requires third party to verify the reliability of public keys sometimes.


1 Answers

Just use the javax.crypto and java.security packages. It's in the Java standard platform.

KeyPair keys = KeyPairGenerator.getInstance("RSA").generateKeyPair();
Cipher cipher = Cipher.getInstance("RSA");
cipher.init(Cipher.ENCRYPT_MODE, keys.getPublic());
byte[] encrypted = cipher.doFinal(rawData);

Links for the official documentation:

  • Package javax.crypto documentation
  • Package java.security documentation
like image 142
kdgregory Avatar answered Oct 21 '22 13:10

kdgregory