zoukankan      html  css  js  c++  java
  • Django 加密解密

     django.core.signing模块

    加密:
    >>> from django.core.signing import Signer
    >>> signer = Signer()
    >>> passwd = signer.sign("123456")
    >>> passwd
    '123456:fgIOAPqsDczcp8QFnZ7dVkOvEE8'
    >>> type(passwd)
    <class 'str'>
    
    解密:
    >>> restore = signer.unsign(passwd)
    >>> restore
    '123456'

    给字典类型数据加密,解密

    列表、元组同样加密解密

    >>> from django.core import signing
    >>> value = signing.dumps({"name": "vv"})
    >>> value
    'eyJuYW1lIjoidnYifQ:1lRtRz:ZJtFIbKWjb75PZROIW1o4dmuWqE'
    >>>
    >>> signing.loads(value)
    {'name': 'vv'}

    参考:

    https://wiki.jikexueyuan.com/project/django-chinese-docs-1.8/8-5-cryptographic-signing.html

  • 相关阅读:
    java final计算
    浅析Java中的final关键字
    easyui
    Java:类与继承
    java中&和&&
    XML
    JSON
    SQL
    selenium
    Metasploit
  • 原文地址:https://www.cnblogs.com/yu121/p/14607316.html
Copyright © 2011-2022 走看看