我是Java的新手,正在尝试使用AES-128对称加密的混合加密技术,然后在生成的对称密钥上使用RSA-1024非对称加密.有人可以帮助我为什么会得到这个例外.我已经关注了其他帖子,并在相应的文件夹中下载了Java Cryptography Extension(JCE)Unlimited Strength Jurisdiction Policy Files第6版.
Code snippet:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.security.Key;
import java.security.InvalidKeyException;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.Security;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.spec.SecretKeySpec;
import java.security.SecureRandom;
public class MainClass {
/**
* @param args
* Encryption and Decryption with AES/ECB/PKCS7Padding and RSA/ECB/PKCS1Padding
*/
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
System.out.println("Enter a Message to be encrypted!");
// Read an input from console
InputStreamReader …Run Code Online (Sandbox Code Playgroud) java encryption cryptography public-key-encryption encryption-symmetric