1. hashlib encryption module: provides many encryption algorithms
Common encryption method: MD5 RSA, irreversible after encryption. Can't be broken.
1. Encrypt a string in MD5 (Python 3)
Example
result
2. Encrypt a string in MD5 (Python 2)
Example
2. In the IO module: StringIO module and BytesIO module
In large-scale development, sometimes it is not necessary to write files to disk, but to use them temporarily and delete them after use. At this time, the StringIO module is used. This module is used to write strings in memory and cache strings. Its interface is the same as that of a file. If you don't need it, just clear it.
The StringIO module can only operate on strings, and the BytesIO module is required to operate on binary data.
1. StringIO module: cache string operations
Example
result
2. BytesIO module: cache binary operations
Example
Note on the result : when it is binary, it will be preceded by b