I have read one article about difference between the methods update() and dofinal() in cipher. It was about what will happend if we want to encrypt 4 Bytes Array, when the bl
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.