Chiffrement des fichiers vidéo

Je suis en utilisant cette méthode de cryptage d'un fichier vidéo:

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);
    }
}

Mais Il donne une erreur Outofmemoryerror disant rejet de l'allocation de 301023321 élément.

1.Est la méthode que je suis à l'utilisation correcte de ces gros fichiers?

2.Si oui, pourquoi j'obtiens cette erreur?Quelle est la solution?

3.Si non veuillez suggérer des bonne méthode pour cela?

source d'informationauteur Navdroid | 2012-02-29