Thread safety with RSA Cipher

前端 未结 2 1178
北荒
北荒 2021-02-10 12:41

As the titles says, i would like to know how to best use Cipher instance in multi threaded environment given the RSA algorithm.

I have read a couple of questions on the

2条回答
  •  遥遥无期
    2021-02-10 13:41

    Encryption (and writing messages) is inherently synchronous. Using multiple threads would not be my approach. Consider a message aabb. With multiple threads that might become abba or baba or abab or bbaa. Note that the internal state of the cipher is also synchronous in that manner ... To get aabb out, you must send aabb in.

提交回复
热议问题