I'm working with RSACryptoServiceProvider
and I looked at examples on some book and on the Internet. In all the examples, a new instance of the type is being created in every method it is being used.
Is it not recommended to create only one RSACryptoServiceProvider
instance and reuse it in all methods?
No - create your own each time, otherwise, once you start using different keys everything is going to go horribly wrong, or if you try to iterate through and need to decrypt something else. Furthermore it has thread safety problems.