Link to home
Start Free TrialLog in
Avatar of AXISHK
AXISHK

asked on

Error in Java program

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
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Sounds like your classpath is wrong and the Bouncy Castle jars are not in it
Avatar of gsk
gsk

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)
Put in classpath these two libraries:

bcprov.jar
bcpkix.jar
Avatar of AXISHK

ASKER

Can't find these jar files, where can I download them ? Thx
Avatar of AXISHK

ASKER

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);
         }
       
    }
ASKER CERTIFIED SOLUTION
Avatar of gsk
gsk

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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?
Thanks AXIHSK,it's nice to see its worked for you.you are most welcome.