AES を使用して文字列を暗号化しました。そのために AES のキーを指定しました。今、私はその特定のキーを RSA で暗号化しようとしています (ここまではすべてうまくいきました)。今度は、この暗号化されたキーを RSA でもう一度暗号化する必要があります。「データは 117 バイトを超えてはなりません」というエラーが表示されます。
public String encrypt(String DATA,String key_string) throws Exception {
String separator = "//msit//";
byte[] data = key_string.getBytes();
MessageDigest sha = MessageDigest.getInstance("SHA-1");
data = sha.digest(data);
data = Arrays.copyOf(data, 16); // use only first 128 bit
SecretKey key = new SecretKeySpec(data, "AES");
String final_matter = DATA + separator;
System.out.println(final_matter);
ecipher = Cipher.getInstance("AES");
ecipher.init(Cipher.ENCRYPT_MODE, key);
byte[] utf8 = final_matter.getBytes("UTF8");
byte[] enc = ecipher.doFinal(utf8);
return new sun.misc.BASE64Encoder().encode(enc);
}