FileInputStream in = null;
File sourceFile = null;
//InputStream PdfViewStream;
ByteArrayOutputStream baos=null ;
sourceFile = new File(sourceFilePath);
try {
baos = new ByteArrayOutputStream((int)sourceFile.length());
if (sourceFile.exists() && sourceFile.isFile())
{
in = new FileInputStream(sourceFile);
Cipher cipher = initAESCipher(key, Cipher.DECRYPT_MODE);
CipherInputStream cipherinputStream = new CipherInputStream(in, cipher);
byte[] buffer = new byte[1024];
int r=0;
while ((r = cipherinputStream.read(buffer)) != -1)
{
//cipherOutputStream.write(buffer, 0, r);
baos.write(buffer, 0, r);
}
ByteArrayInputStream is = new ByteArrayInputStream(outputStream.toByteArray());
这ByteArrayInputStream is = new ByteArrayInputStream(outputStream.toByteArray());一句崩溃,求解。
android读取加密文件之后解密后可以直接显示吗?还是要再缓存到一个文件里,然后再读取?如果这样,那这个解密后的文件岂不是没有保护?那加密还有意义吗?