Install JCE and bouncycastle software for encryption.

Source: Internet
Author: User
Some days ago I find this information about (I can not remind where did I take it, maybe was from this forum) for install JCE and bouncycastle software for encryption.

You shoshould first download change the policy of the JCE by downloading this
Http://java.sun.com/j2se/1.4.2/download.html just jce a and unzip in a folder read the read me Doc so you shocould cut that 2 file and put here C: \ j2sdk1.4.2 _ 02 \ JRE \ Lib \ Security
And here c: \ Program Files \ Java \ j2re1.4.2 _ 02 \ Lib \ Security

Done this then download the bouncy JAR file from the http://www.bouncycastle.org/latest_releases.html take the bcprov-jdk14-120.jar and put in following directories

C: \ j2sdk1.4.2 _ 02 \ JRE \ Lib \ ext
C: \ Program Files \ Java \ j2re1.4.2 _ 02 \ Lib \ ext

Then you need to change the environment variable so in the following directories open "Java. Security" in both
C: \ j2sdk1.4.2 _ 02 \ JRE \ Lib \ Security
C: \ Program Files \ Java \ j2re1.4.2 _ 02 \ Lib \ Security

And edit it and add the extra line

Security. provider. numberprovider = org. bouncycastle. JCE. provider. bouncycastleprov ider

Then you shoshould test if everything is good installed:

import java.security.Provider;import java.security.Security;import java.util.Set;import java.util.Iterator; public class Verifica { public static void main(String[] args) {Provider[] providers = Security.getProviders();for (int i = 0; i < providers.length; i++) {Provider provider = providers[i];System.out.println("Provider name: " + provider.getName());System.out.println("Provider information: " + provider.getInfo());System.out.println("Provider version: " + provider.getVersion());Set entries = provider.entrySet();Iterator iterator = entries.iterator();/*while (iterator.hasNext()) {System.out.println("Property entry: " + iterator.next());}*/}}

And you will see if there is RSA. (It shocould)

An example:

Encription:

//Object Cipher to encript data.Cipher encriptDatos = Cipher.getInstance("RSA", "BC"); encriptDatos.init(Cipher.ENCRYPT_MODE, servidorPub); //servidorPub is the server public key you should have or generate //data encryptionbyte[] datosEncriptados = encriptDatos.doFinal(b);


Desencryption:

Cipher Cipherdesencriptacion = Cipher.getInstance("RSA", "BC");Cipherdesencriptacion.init(Cipher.DECRYPT_MODE, servidorPriv); //ServidorPriv is the server public key
//data desencryptionbyte[] datosClaros = Cipherdesencriptacion.doFinal(datos); //datos = encripted data.

I am sure you can find your examples of encrypt and decrypt. But hope this help as introduction.

-Susana

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.