how to decrypt a large file in java / android -


main

i looking way encrypt file , decrypt on android device. best solution was: encrypt file openssl decrypt in java using method shown here.

problem: file apparently large (5 mb) , 'out of memory' exception when running on android emulator.

additional

i thankful if add following answer, though if have answer previous section fine:

  1. compression: using zip archive compress encrypted file. has minor effect (20% compression on encrypted file vs 80% on non encrypted version of file). there better way this?
  2. encryption method: able compress file using standard linux commands i.e. openssl aes-256-cbc -a -salt -in password.txt -out password.txt.enc
  3. fast on secure: prefer fast decryption method, on cost of being not secure method.

your main issue you're trying keep in memory (obviously). i'd recommend changes in workflow:

  • get rid of base64-encoding files. there multiple issues that, 1 files larger need be, 1 other need decode encoding (which reduce performance, if tiny bit).
  • do not load data memory (byte arrays). need address issue, that's memory issue comes from. use streams instead of byte array, hold chunks of data in memory.
  • as mentioned in comment, compress before encryption. encrypted data should random numbers, , random numbers can't compressed well. note uncompressing files impacts cpu performance (but goes along faster transmissions)

Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -