And for virtually anything that is stateful.

I honestly don’t think the problem is with encapsulation as such, but more with poor class design. Should the IV be passed in the encryptor ctor in this example, you’d already have implemented better design in my opinion. Every subsequent call would be using that IV.

Your method would work as well, but it beats the point of having a class instance to begin with — it may as well be a static function.

Software Engineer writing about his daily software adventures, wherever they may lead.

Software Engineer writing about his daily software adventures, wherever they may lead.