Что такое Entity в Android? - PullRequest
       10

Что такое Entity в Android?

0 голосов
/ 13 декабря 2018

Я новичок в Android. Я использую приведенный ниже код (Facebook Conceal Library) для шифрования и дешифрования видео, но я не знаю точно, что такое Entity? Я много раз искал в сети, а также посетил developer.android.com/reference/android/content/Entity но я не знаю, что мне еще использовать для Entity?

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();
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...