没有在Eclipse中的Bouncy Castle的NoSuchAlgorithmException

时间:2017-03-16 15:10:22

标签: java maven bouncycastle

我们使用充气城堡进行加密。 当我们在Eclipse中以调试模式编写代码时,我们没有任何问题,但是当我们手动启动JAR时,我们有一个NoSuchAlgorithmException。 JAR使用maven插件配置

构建
<dependencies>
    <dependency>
        <groupId>org.bouncycastle</groupId>
        <artifactId>bcprov-jdk15on</artifactId>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                        <createDependencyReducedPom>false</createDependencyReducedPom>
                        <minimizeJar>false</minimizeJar>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

这是我们的代码:

Security.insertProviderAt(new BouncyCastleProvider(), 1);
Cipher cipher = Cipher.getInstance("RSA/None/OAEPWithSHA256AndMGF1Padding");
cipher.init(Cipher.DECRYPT_MODE, privateKey);
return cipher.doFinal(data);

我们已将安全策略更改为Oracle提供的无限制安全策略,但问题仍然存在。 有什么想法吗?

0 个答案:

没有答案