Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
  • Piet Souris
  • Himai Minh

Cipher error

Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Cannot find any provider supporting DES/ECB/PKCS5Padding." This error is appearing when Cipher.getInstance is executed. I can not figure out why. I have looked to make sure javax.crypto.Cipher is listed. It is.

import javax.crypto.*;
import javax.crypto.Cipher;
import sun.misc.*;
import java.util.*;
import java.sql.*;

public class Decrypt{

public String getDecryptedString(String input)throws DecryptError

try {

Security.addProvider( new com.sun.crypto.provider.SunJCE() );
Key key = null;

FileInputStream in = new FileInputStream("CONFIG/Key.dat");
ObjectInputStream s = new ObjectInputStream(in);

key = (Key)s.readObject();

Cipher cipher = Cipher.getInstance("DES/ECB/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, key);

BASE64Decoder decoder = new BASE64Decoder();
byte[] out = decoder.decodeBuffer(input);

byte[] outputBytes = cipher.doFinal(out);

return new String(outputBytes);
catch (Exception e)
throw new DecryptError(e.getMessage());
}//end Decrypt class
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sounds like the sunjce_provider.jar is not in your classpath.
Why is the word "abbreviation" so long? And this ad is so short?
Free, earth friendly heat - from the CodeRanch trailboss
    Bookmark Topic Watch Topic
  • New Topic