zoukankan      html  css  js  c++  java
  • 使用BC库解密出现no such provider错误

    使用BC库解密出现no such provider错误

    错误提示如下:
    Exception in thread "main" java.security.NoSuchProviderException: no such provider: BC
            at sun.security.jca.GetInstance.getService(GetInstance.java:83)
            at sun.security.jca.GetInstance.getInstance(GetInstance.java:206)
            at java.security.KeyFactory.getInstance(KeyFactory.java:211)
    
    解决方式
    1. edit jrelibsecurityjava.security 
    add security.provider.10=org.bouncycastle.jce.provider.BouncyCastleProvider 
    2. copy bc*.jar to jrelibext 
    
    • 但是上面这种方式并不在某些情况下不适用,又找到了另外一个方式,在代码里用到的地方前添加如下代码:
    if (Security.getProvider("BC") == null) { 
    Security.addProvider(new BouncyCastleProvider()); 
    } 
    
    
    or
    
            Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
    
  • 相关阅读:
    加工零件(Dijkstra)
    尼克的任务(DP)
    挖地雷(记忆化搜索)
    滑雪(DP,记忆化搜索)
    子串和子序列(DP)
    八皇后(DFS)
    打印feign报错日志
    restTemplate 踩坑
    共享全局对象
    获取当月多少天
  • 原文地址:https://www.cnblogs.com/wswang/p/7718150.html
Copyright © 2011-2022 走看看