zoukankan      html  css  js  c++  java
  • python加密模块学习

    1. md5模块

        md5.new([arg])     返回一个md5对象,如果给出参数,则相当于调用了update(arg)

        md5.update(arg)   用string参数arg更新md5对象

        md5.digest()         返回16字节的摘要,由传给update的string生成,摘要没有ascii字符

        md5.hexdigest()    以16进制的形式返回摘要

    import md5
    a = md5.new('passwd')
    a.digest()
       'vxa2x17;xe692Txe7/xfaMmxf1x03
    '
    
    a.hexdigest()
       '76a2173be6393254e72ffa4d6df1030a'
    
    a.update('hello world')
    a.digest()
       'xb2x83fxb8x14xc9xc6x19kx01xfexd8xd9x8fxe0H'
    
    a.hexdigest()
       'b28366b814c9c6196b01fed8d98fe048'
     

    2.sha 模块

    用法同md5一样

    import sha
    b=sha.new('passwd')
    b.digest()
      "0'LGx90;xd1xbaxc7c;xbf	t1Ixebxabx80_"
    
    b.hexdigest()
      '30274c47903bd1bac7633bbf09743149ebab805f'
    
    b.update('hello')
    b.digest()
      'cxc19xb4]YGzx85xe8Cx8fFxfex9exc3|xb16xba'
    
    b.hexdigest()
      '63c139b45d59477a85e8438f46fe9ec37cb136ba

    3.crypt

      crypt模块中就一个函数,crypt(str,salt) --> string 

    from crypt import crypt 
    
    crypt('passwd','a')
      'aaIslqfNH03LA'
    
    crypt('passwd','abc')
      'ab8RogIKnX0og'
    
    crypt('passwd','a')
      'aaIslqfNH03LA'
  • 相关阅读:
    代码规范圣战
    代码复审结果
    个人工程总结
    第一周个人博客作业
    软工课程总结
    软件工程课程的建议
    大泥球你好~
    第一次会议记录
    软件工程的瀑布, 大泥球, 教堂,集市,和银弹
    vs2013——单元测试&& 性能图
  • 原文地址:https://www.cnblogs.com/cmsd/p/3314157.html
Copyright © 2011-2022 走看看