BouncyCastle 和算法错误

Error with BouncyCastle and Algorithm

我在 Windows

上使用 BouncyCastle 和 PBEWITHSHAAND256BITAES-CBC-BC 算法时遇到错误

我的代码:

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

并给我错误:

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)

您正在附加新的提供商。在第一行使用此代码:

 Security.insertProviderAt(new BouncyCastleProvider(), 1);