Install and configure bouncycastle JCE

Source: Internet
Author: User

1. Install the bouncycastle. JAR File

Find the file and perform the following two steps:

(1) copy the file to the jdk1.3.1/JRE/lib/EXT/directory.

(2) copy the file to the C:/ProgramFiles/program oft/JRE/1.3/lib/EXT directory.

Note that the preceding two steps must be completed.

2. Configure the java. Security File

First, find the following two files:

(1) jdk1.3.1/JRE/lib/security/Java. Security File

(2) c:/ProgramFiles/kerberoft/JRE/1.3/lib/security/Java. Security

Open the above two files and find the following statement:

Security. provider.1 = sun. Security. provider. Sun

Security. provider.2 = com. Sun. rsajca. Provider

Add the following statement to the end of the preceding statement:

Security. provider.3 = org. bouncycastle. JCE. provider. bouncycastleprovider

Note that:

(1) Both files must be modified.

(2) the case cannot be incorrect.

3. test whether the installation is correct

Check whether the jceinstalltest. Java program exists in two cases:

(1) have this program

You compile and run it. As follows:

A. javac jceinstalltest. Java

B. Java jceinstalltest

Note the case sensitivity. If the output is generated, the installation is correct. Otherwise, follow the previous steps to check for errors.

(2) The program does not exist.

You can copy this program from this document and compile and run it as needed.

The jceinstalltest. Java program code is as follows:

* ************************* Jceinstalltest. java ***************************

Import javax. crypto .*;

Public class jceinstalltest {

Public static final string stringtoencrypt = "this is a test .";

Public static void main (string [] ARGs) throws exception {

System. Out. Print ("attempting to get a blowfish key ...");

Keygenerator = keygenerator. getinstance ("Blowfish ");

Keygenerator. INIT (128 );

Secretkey key = keygenerator. generatekey ();

System. Out. println ("OK ");

System. Out. println ("attempting to get a cipher and encrypt ...");

Cipher cipher = cipher. getinstance ("Blowfish/ECB/pkcs5padding ");

Cipher. INIT (Cipher. encrypt_mode, key );

Byte [] ciphertext = cipher. dofinal (stringtoencrypt. getbytes ("utf8 "));

System. Out. println ("OK ");

System. Out. println ("test completed successfully .");

}

}

* *************************** Jceinstalltest. java *************************

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.