I wasn't familiar with what you're asking about, but it looks like you're referring to
streams. However, encode and decode there aren't part of strings, they're part of normal string operations (it looks like you were confused, reading the docs). As far as that goes, I'm not sure what you mean about security with respect to those two methods. It's just a matter of whether you're treating a bunch of characters as lower-level bytes or a unicode string.
I'm afraid you're asking a question with some goal in mind. It might be helpful to tell us the goal, and we can help you get there, rather than trying to go through things that could potentially be skipped to get to your goal.