Error in Java program

AXISHK
AXISHK used Ask the Experts™
on
An error in my Java code with the message "package org.bouncycastle.jce.provider does not exist". Any idea how to fix it ? I'm using Java 8.

Thx
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016

Commented:
Sounds like your classpath is wrong and the Bouncy Castle jars are not in it
gskTechnology consultant

Commented:
It seems package org.bouncycastle.jce.provider  is missing ,please look for package in your project structure naming
 org.bouncycastle.jce.provider.proper jars should be in the place (in the build path if required dependency)

Commented:
Put in classpath these two libraries:

bcprov.jar
bcpkix.jar
Introduction to R

R is considered the predominant language for data scientist and statisticians. Learn how to use R for your own data science projects.

Author

Commented:
Can't find these jar files, where can I download them ? Thx

Author

Commented:
I have downloaded the JAR File : http://www.java2s.com/Code/Jar/b/Downloadbouncycastlejcejdk13112jar.htm and put it under the library of my NetBean project. However, another message prompt up.


No such algorithm: DES/CRT/Nopadding. Any idea ?


    private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {                                        
       
        try {
           Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());

            input = Simple_txt.getText().getBytes();
            SecretKeySpec key = new SecretKeySpec(keyBytes, "DES");
            IvParameterSpec ivSpec = new IvParameterSpec(ivBytes);
           
            cipher = Cipher.getInstance("DES/CRT/NoPadding", "BC");
            cipher.init(Cipher.ENCRYPT_MODE, key,ivSpec);
           
            cipherText = new byte[cipher.getOutputSize(input.length)];
           
           ctLength = cipher.update(input, 0, input.length, cipherText, 0);
           
           ctLength += cipher.doFinal(cipherText, ctLength);
           Encrypt_txt.setText(new String(cipherText));
           System.out.println("cipher: " + new String(cipherText));
           
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null, ex);
         }
       
    }
Technology consultant
Commented:
What I can suggest at the moment that please put the jar in proper build path,secondly please start program in debug bug mode,run as java application in debug mode,press F5 ,F6 (hope you well aware) .Generally if jar is not there then IDE gives red color error in project,please put jars in lib folder(if exists) or in some proper directory.clean the porject.again run as java application,hope its simple java class.

please try and check whether it works.

thanks
Top Expert 2016

Commented:
Cipher.getInstance("DES/CRT/NoPadding", "BC");

Open in new window


What code have you got that leads you to believe that algo is possible from that provider and where did you get it?
gskTechnology consultant

Commented:
Thanks AXIHSK,it's nice to see its worked for you.you are most welcome.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial