资讯专栏INFORMATION COLUMN

Difference between the methods update() and doFina

khs1994 / 2622人阅读

update() adds data to the Cipher’s internal buffer, then returns all currently completely encoded blocks. If there are any encoded blocks left over, they remain in the Cipher’s buffer until the next call, or a call to doFinal(). This means that if you call update() with a four byte array to encrypt, and the buffer size is eight bytes, you will not receive encoded data on the return (you’ll get a null instead). If your next call to update() passes five bytes of data in, you will get an 8 byte (the block size) array back, containing the four bytes passed in on the previous call, the first four bytes from the current call – the remaining byte from the current call is left in the Cipher’s buffer.

doFinal() on the other hand is much simpler: it encrypts the passed data, pads it out to the necessary length, and then returns it. The Cipher is essentially stateless.

原文链接:http://esus.com/difference-me...

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/65169.html

相关文章

  • 从 Quora 的 187 个问题中学习机器学习和NLP

    摘要:许多的顶尖研究人员都会积极的在现场回答问题。虽然有许多主题的常见问题页面比如,这是一个机器学习的,但是这些都是非常不全面的,或者不够精致。在这篇文章中,我试图做一个更加全面的有关机器学习和问题的。 作者:chen_h微信号 & QQ:862251340微信公众号:coderpai简书地址:http://www.jianshu.com/p/ac18... showImg(https:/...

    hidogs 评论0 收藏0
  • Java Interview Questions (1)

    What is Java? Java is a high-level platform-independent object oriented programming language. List some features of Java? Object Oriented, Platform Independent, Multi-threaded, Interpreted, Robust, pa...

    xuxueli 评论0 收藏0
  • Java interview question

    what is the difference between overriding and overloading? Overriding is resolved at runtime while overloading is compile time. Override: is a language feature that allows a subclass to provide a spec...

    thekingisalwaysluc 评论0 收藏0
  • Java中wait()与sleep()的区别

    摘要:期间对象锁是释放的调用的时候锁并没有被释放,调用也属于这种情况一般而言,用于线程间的通信,用于线程状态的控制参考资料 最近在做面试题的时候看到这道题,复习了一遍《Thinking in Java》,在此记录这个答案 类的区别 wait()来自于 java.lang.Object,任何对象都有此方法 sleep()来自于 java.lang.Thread,调用的对象为线程 ...

    seanHai 评论0 收藏0
  • [LintCode] Minimum Absolute Difference in BST

    Problem Minimum Absolute Difference in BSTGiven a binary search tree with non-negative values, find the minimum absolute difference between values of any two nodes. Example Input: 1 3 ...

    curlyCheng 评论0 收藏0

发表评论

0条评论

最新活动
阅读需要支付1元查看
<