Encryption of image files on Android — Cipher(Output|Input)Stream problems

前端 未结 2 1355
星月不相逢
星月不相逢 2020-12-24 15:56

I\'m trying to encrypt image files on Android with password based encryption. To save the encrypted image I just do this:

FileOutputStream fos = new FileOutp         


        
相关标签:
2条回答
  • 2020-12-24 16:05

    When writing to a CipherOutputStream, make sure you close() the stream after writing the data (and not closing the underlying stream before it). Closing makes sure the right padding is added. A flush() alone is not enough here.

    Also, I would advise to not use DES for new protocols - preferred nowadays is AES.

    0 讨论(0)
  • 2020-12-24 16:10

    You could subclass CipherOutputStream or even just OutputStream, and just override the flush() method to do nothing.

    0 讨论(0)
提交回复
热议问题