Thread safety with RSA Cipher

前端 未结 2 1754
伪装坚强ぢ
伪装坚强ぢ 2021-02-10 13:01

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:30

    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.

提交回复
热议问题