我在项目中有视频,为了安全起见,我加密了视频文件,这样做效果还不错。但问题是...(未完待续)
**videoView.setVideoPath("/mnt/sdcard/intro_video.3gp");**
在这个方法中,我需要传递文件(已解密)。因此,我正在为文件路径创建解密文件,并尝试直接在视频视图中传递解密后的字节。我正在使用Cipher进行加密。
下面是我的代码:
private void decryption()throws Exception {
// TODO Auto-generated method stub
String filePath2 = path + "en/encVideo";
String filePath3 = path + "de/decVideo";
File decfile = new File(filePath3);
if(!decfile.exists())
decfile.createNewFile();
File outfile = new File(filePath2);
int read;
FileInputStream encfis = new FileInputStream(outfile);
Cipher decipher = Cipher.getInstance("AES");
decipher.init(Cipher.DECRYPT_MODE, skey);
FileOutputStream decfos = new FileOutputStream(decfile);
CipherOutputStream cos = new CipherOutputStream(decfos,decipher);
while((read=encfis.read()) != -1)
{
cos.write(read);
cos.flush();
}
cos.close();
}