Martin Cerruti
1 min readNov 12, 2018

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.

Martin Cerruti

Software Architect, Technology Writer, but most of all a programmer.