在Windows上,BouncyCastle和pbewithshaand256bites-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);