2

i have error with BouncyCastle and PBEWITHSHAAND256BITAES-CBC-BC Algorithm on Windows

My Code:

Security.addProvider(new BouncyCastleProvider());
SecretKeyFactory localSecretKeyFactory = SecretKeyFactory.getInstance("PBEWITHSHAAND256BITAES-CBC-BC");

And Give me error:

java.security.NoSuchAlgorithmException: PBEWITHSHAAND256BITAES-CBC-BC SecretKeyFactory not available
    at javax.crypto.SecretKeyFactory.<init>(SecretKeyFactory.java:122)
    at javax.crypto.SecretKeyFactory.getInstance(SecretKeyFactory.java:160)
    at pl.edu.tirex.server.KeyFactory.<init>(KeyFactory.java:28)
    at pl.edu.tirex.server.Main.main(Main.java:29)
Szymon
  • 75
  • 12
  • possible duplicate: http://stackoverflow.com/questions/24578141/nosuchalgorithmexception-pbewithsha256and128bitaes – bro Aug 21 '15 at 13:08

1 Answers1

3

You're appending the new provider. Use this code for your first line:

 Security.insertProviderAt(new BouncyCastleProvider(), 1);
Benjamin Marwell
  • 1,173
  • 1
  • 13
  • 36