需要 python 3.6+

    1. pip install cryptography

    使用

    1. from cryptography.fernet import Fernet
    2. key = Fernet.generate_key()
    3. f = Fernet(key)
    4. token = f.encrypt(b'welcome to django')
    5. print(token)
    6. d = f.decrypt(token)
    7. print(d)