我是java的新手,所以请原谅我愚蠢的问题
1)我的项目从netbeans 6转移到8
2)jdk从6u45移动到8u11
3)调试
后成功设置到新环境出错:javax.crypto.IllegalBlockSizeException:最后一个块 解密不完整
堆栈跟踪:
com.alstom.tsoft.controller.system.ParameterTablesController $ LoadOfflineWorker - [javax.crypto.CipherInputStream.getMoreData(CipherInputStream.java:121), javax.crypto.CipherInputStream.read(CipherInputStream.java:192), com.alstom.tsoft.crypto.CryptoManager.decryptString(CryptoManager.java:146), com.alstom.tsoft.io.CryptedFieldReader.readField(CryptedFieldReader.java:58),
4)以前environment(jdk6 and netbeans 6)
中从未发生过,这是项目中唯一的变化。
我们正在使用以下输入:
private static final String ALGO_TYPE = "AES";
private static final String ALGO_FULL_NAME = "AES/ECB/PKCS5Padding";
private static final String ALGO_PROVIDER = "BC";
public String encryptString(String input) throws NoSuchAlgorithmException,NoSuchProviderException,
NoSuchPaddingException,InvalidKeyException,IOException {
StringBuffer output = new StringBuffer();
CipherInputStream cis = new CipherInputStream(
new ByteArrayInputStream(input.getBytes()),
getEncryptionCipher());
int b;
while ( ( b = cis.read() ) != -1 ) {
String twoHexDigit = String.format("%1$02x",b);
//m_logger.info(":"+b+":"+twoHexDigit.toUpperCase());
output.append(twoHexDigit.toUpperCase());
}
return output.toString();
}
//Dencryption
public String decryptString(String input) throws NoSuchAlgorithmException,NoSuchProviderException,
NoSuchPaddingException,InvalidKeyException,IOException {
StringBuffer output = new StringBuffer();
byte[] inputBytes = convertHexStringToByte(input);
CipherInputStream cis = new CipherInputStream(
new ByteArrayInputStream(inputBytes),
getDecryptionCipher());
int b;
while ( ( b = cis.read() ) != -1 ) {
output.append(new Character((char)b));
}
return output.toString();
}
请告知我在哪里做错了以及如何调试
提前致谢