我是android的初学者。我正在使用下面的代码(Facebook隐藏库)来加密和解密视频,但我不知道Entity到底是什么?我在网上搜索了很多次,还访问了{{3 }},但我仍然不知道该对实体使用什么?
public void testEncrypt()
{
File inputFile = new File("/storage/emulated/0/Download/video1.mp4");
try {
final byte[] encrypt = new byte[(int) inputFile.length()];
ContextWrapper cw = new ContextWrapper(getApplicationContext());
File directory = cw.getDir("/storage/emulated/0/Download/", Context.MODE_PRIVATE);
File mypath = new File(directory, "encrypt.mp4");
Crypto crypto = new Crypto(new SharedPrefsBackedKeyChain(this), new SystemNativeCryptoLibrary());
if (!crypto.isAvailable()) {
return;
}
OutputStream fileStream = new BufferedOutputStream(
new FileOutputStream(mypath));
OutputStream outputStream = crypto.getCipherOutputStream(
fileStream, new **Entity()**);
outputStream.write(encrypt);
outputStream.close();
} catch (UnsupportedOperationException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
Toast.makeText(MainActivity.this,"Encrypted",Toast.LENGTH_LONG).show();
}
public Void testDecrypt() {
Crypto crypto = new Crypto(new SharedPrefsBackedKeyChain(this),
new SystemNativeCryptoLibrary());
ContextWrapper cw = new ContextWrapper(getApplicationContext());
File directory = cw.getDir("/storage/emulated/0/Download/", Context.MODE_PRIVATE);
File file = new File(directory, "decrypt.mp4");
try {
FileInputStream fileStream = new FileInputStream(file);
InputStream inputStream = crypto.getCipherInputStream(fileStream,
new **Entity()**);
ByteArrayOutputStream out = new ByteArrayOutputStream();
int read;
byte[] buffer = new byte[1024];
while ((read = inputStream.read(buffer)) != -1) {
out.write(buffer, 0, read);
}
inputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
Toast.makeText(MainActivity.this, "Decrypted", Toast.LENGTH_LONG).show();
}