android - 什么是android中的实体?
问题描述
我是android的初学者。我正在使用下面的代码(Facebook Conceal Library)来加密和解密视频,但我不知道实体到底是什么?我在网上搜索了很多次,也访问了developer.android.com/参考/安卓/内容/实体,但我不知道我应该为实体使用什么?
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();
}
解决方案
推荐阅读
- macos - Microsoft 添加 ins 功能区自定义选项卡在 Outlook 中不起作用
- java - HashSet 代替 ArrayList 在性能上的缺点
- clojure - Clojure:实现一些功能
- angular - 离子原生联系人“plugin_not_installed”
- html - 我们可以从/输入数据保存到同一个html文件吗
- sql - SSIS:我需要从 For Each 循环中的 2 个不同查询填充 2 个 Excel 电子表格
- javascript - 使用带有类的 setInterval() 交换图像 – p5.js
- java - 在处理中增加 textSize
- hibernate - Netbeans为什么显示空白?
- javascript - IOS Voiceover 不读取 div 内容