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 *************************