相关疑难解决方法(0)

加密视频文件?

我正在使用此方法加密视频文件:

public static void encryptToBinaryFile(String password, byte[] bytes, File file) throws EncrypterException {
    try {
        final byte[] rawKey = getRawKey(password.getBytes());
        final FileOutputStream ostream = new FileOutputStream(file, false);

        ostream.write(encrypt(rawKey, bytes));
        ostream.flush();
        ostream.close();

    } catch (IOException e) {
        throw new EncrypterException(e);
    }
}

private static byte[] encrypt(byte[] raw, byte[] clear) throws EncrypterException {
    try {
       final SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
       final Cipher cipher = Cipher.getInstance("AES");
       cipher.init(Cipher.ENCRYPT_MODE, skeySpec);

       return cipher.doFinal(clear);

    } catch (Exception e) {
        throw new EncrypterException(e);
    }
}
Run Code Online (Sandbox Code Playgroud)

但它给出了一个错误Outofmemoryerror说拒绝分配301023321元素. …

java encryption android file out-of-memory

14
推荐指数
2
解决办法
2万
查看次数

标签 统计

android ×1

encryption ×1

file ×1

java ×1

out-of-memory ×1