Android AES-128 encryption/decryption of file is very slow. How can I increase the speed

前端 未结 2 2052
遇见更好的自我
遇见更好的自我 2021-02-03 15:29

I am developing an android app that secures images and videos like Vaulty and Keep safe. I am trying to use AES-128 encryption/decryption technique to store images and videos. I

2条回答
  •  花落未央
    2021-02-03 15:40

    One thing that is making your code run slow is the size of your buffer:

    byte[] d = new byte[8];
    

    You should bump it up by a few orders of magnitude if you want it to run fast. Given the size of your files I would suggest using at least 1 MB but nowadays you can realistically set it to a few MBs, even on Android. Try changing it to:

    byte[] d = new byte[1024 * 1024];
    

    and let us know how much did that improve the speed by.

提交回复
热议问题