difference between the methods update() and dofinal() in cipher

主宰稳场 提交于 2019-12-02 05:35:20
  • update(): feed the data, again and again, enables you to encrypt long files, streams.

  • dofinal(): apply the requested padding scheme to the data, if requested and necessary, then encrypt. ECB and CBC mode requires padding but CTR mode doesn't. If NOPADDING has used some libraries may secretly pad, in others you have to handle the padding yourself.

When you call, dofinal() with 4-byte data, if NOPADDING is not set, it will be padded and then encrypted.

From Java Doc;

  • update(byte[] input) Continues a multiple-part encryption or decryption operation (depending on how this cipher was initialized), processing another data part.
  • doFinal() Finishes a multiple-part encryption or decryption operation, depending on how this cipher was initialized.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!