像SHA256哈希的一点是,它应该是一个单向函数(尽管真正的单向函数的存在仍是一个悬而未决的问题,请参见http://en.wikipedia.org/wiki/One-way_function)。
The ideal cryptographic hash function has four main properties:
1. it is easy to compute the hash value for any given message
2. it is infeasible to generate a message that has a given hash
3. it is infeasible to modify a message without changing the hash
4. it is infeasible to find two different messages with the same hash.
from Crypto.Cipher import AES
import base64
cipher = AES.new(secret_key,AES.MODE_ECB) # never use ECB in strong systems obviously
encoded = base64.b64encode(cipher.encrypt(msg_text))
# ...
decoded = cipher.decrypt(baes64.b64decode(msg_text))