Non-Unicode Encodings
Although most of the earlier examples used Unicode encodings, codecs
The example codes as follows:
import codecs
import io
buffer = io.StringIO()
stream = codecs.getwriter('rot_13')(buffer)
text = 'abcdefghijklmnopqrstuvwxyz'
stream.write(text)
stream.flush()
print('Original:', text)
print('ROT-13 :', buffer.getvalue())
The result of running application follow:
D:\Python39\python.exe D:/My_Project/codecs_rot13.py
Original: abcdefghijklmnopqrstuvwxyz
ROT-13 : nopqrstuvwxyzabcdefghijklm
Process finished with exit code 0
You can use this case to encrypt some passwords.