def get_cookie_info(): req_cookie = request.cookies.get('cookie_info') if req_cookie is not None: try: aes_crypt = AesCrypt(AES_KEY) # 初始化密钥 aes_crypt_cookie = aes_crypt.decrypt(req_cookie) req_cookie = json.loads(aes_crypt_cookie) return req_cookie except: return {} else: return {}
def aes_decrypt(text): aes_crypt = AesCrypt(AES_KEY) # 初始化密钥 decrypt_text = aes_crypt.decrypt(text) # 解密成字符串 return decrypt_text
def aes_encrypt(text): aes_crypt = AesCrypt(AES_KEY) # 初始化密钥 encrypt_text = aes_crypt.encrypt(text) # 加密字符串 return encrypt_text