zoukankan      html  css  js  c++  java
  • python学习,day5:内置模块(hashlib,加密)

    p3.0 ,sha和md5加密都集成到hashlib模块中

    # coding=utf-8
    # Author: RyAn Bi
    import hashlib     #支持加密,sha和md5
    m = hashlib.md5()
    m.update(b"hello")
    print(m.hexdigest())
    m.update(b"It's me")   #等同于m2.update(b"helloIt's me"),是前两个的结合
    print(m.hexdigest())
    m.update(b"it's been a long time since we spoken")
    print(m.hexdigest())
    
    m2 =hashlib.md5()
    m2.update(b"helloIt's me")
    print(m2.hexdigest())
    
    s2 = hashlib.sha1()
    s2.update(b"helloIt's me")
    print(s2.hexdigest())
    
    import hmac      #消息加密,速度比较快
    h=hmac.new("天王盖地虎".encode(encoding='utf-8'),"你是250".encode(encoding='utf-8'))  #前面是key,后面是消息,中文必须要encode
    print(h.digest())
    print(h.hexdigest())
    

      

  • 相关阅读:
    Go反射
    Go_CSP并发模型
    Go_select
    Go计时器
    day9:vcp考试
    day8:vcp考试
    day7:vcp考试
    day6:vcp考试
    day5:vcp考试
    day4:vcp考试
  • 原文地址:https://www.cnblogs.com/bbgoal/p/11381581.html
Copyright © 2011-2022 走看看