📅 2012-May-14 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ python, rot13 ⬩ 📚 Archive
Obtaining the ROT13 encoding of a string used to be easy in Python 2.x:
= "Hello"
s = s.encode( "rot13" )
os print( os ) # "Uryyb"
This no longer works in Python 3.x. The solution that works in Python 3.x is to access low-level functions in the codecs module:
import codecs
= "Hello"
s = codecs.getencoder( "rot-13" )
enc = enc( s )[0]
os
print( os ) # "Uryyb"
Tried with: Python 3.2.3