• hashlib模块subprocess模块


    '''
    通过一种算法,将字符串得出一种编码
    内容相同则hash运算结果相同,内容稍微改变则hash值改变
    不可逆推
    相同算法,无论校验多长的数据,得到的hash值长度固定
    '''
    # import hashlib
    # m=hashlib.md5()
    # m.update('hello'.encode('utf-8'))
    # m.update('world'.encode('utf-8'))
    # print(m.hexdigest()) # fc5e038d38a57032085441e7fe7010b0
    # import hashlib
    # m1=hashlib.md5()
    # m1.update('helloworl'.encode('utf-8'))
    # m1.update('d'.encode('utf-8'))
    # print(m1.hexdigest()) # fc5e038d38a57032085441e7fe7010b0
    # import hashlib
    # name=input('>>:name')
    # pwd=input('>>:pwd')
    # m=hashlib.md5()
    # m.update(pwd.encode('utf-8'))
    # pwd=m.hexdigest()
    # print(name,pwd) # egon 202cb962ac59075b964b07152d234b70
    # import hashlib
    # cryt_pwd='202cb962ac59075b964b07152d234b70'
    # pwds=[
    # '123456',
    # '12345',
    # '123'
    # ]
    # def make_dic(pwds):
    # dic={}
    # for pwd in pwds:
    # m=hashlib.md5(pwd.encode('utf-8'))
    # dic[pwd]=m.hexdigest()
    # return dic
    # print(make_dic(pwds))
    '''
    {'123456': 'e10adc3949ba59abbe56e057f20f883e', '12345': '827ccb0eea8a706c4c34a16891f84e7b', '123': '202cb962ac59075b964b07152d234b70'}
    '''
    # import hashlib
    # cryt_pwd='202cb962ac59075b964b07152d234b70'
    # pwds=[
    # '123456',
    # '12345',
    # '123'
    # ]
    # def make_dic(pwds):
    # dic={}
    # for pwd in pwds:
    # m=hashlib.md5(pwd.encode('utf-8'))
    # dic[pwd]=m.hexdigest()
    # return dic
    # dic=make_dic(pwds)
    # for pwd in dic:
    # if dic[pwd] == cryt_pwd:
    # print(pwd)
    '''
    123
    '''
    # import hashlib
    # m=hashlib.md5()
    # m.update('123'.encode('utf-8'))
    # print(m.hexdigest())
    '''
    202cb962ac59075b964b07152d234b70
    '''
    # import hashlib
    # m=hashlib.sha512()
    # m.update('123'.encode('utf-8'))
    # print(m.hexdigest())
    '''
    3c9909afec25354d551dae21590bb26e38d53f2173b8d3dc3eee4c047e7ab1c1eb8b85103e3be7ba613b31bb5c9c36214dc9f14a42fd7a2fdb84856bca5c44c2
    '''
    # import hashlib
    # m=hashlib.md5('春宵一刻值千金'.encode('utf-8'))
    # m.update('123'.encode('utf-8'))
    # m.update('花有清香月有阴'.encode('utf-8'))
    # print(m.hexdigest())
    '''
    f4e3c0b586c48c46ea50ea3467323c77
    '''
    # import hmac
    # m=hmac.new('加盐'.encode('utf-8'))
    # m.update('123'.encode('utf-8'))
    # print(m.hexdigest())
    '''
    72e6bfeeacfc4b546338c9453205d1db
    '''
    # subprocess模块
    # import subprocess,time
    # subprocess.Popen('tasklist',shell=True)
    # print('>>:主')
    # time.sleep(1)

    # import subprocess,time
    # subprocess.Popen('tasklist',shell=True,
    # stdout=subprocess.PIPE,
    # stderr=subprocess.PIPE)
    # print('>>:主')
    # time.sleep(1)

    # import subprocess,time
    # obj=subprocess.Popen('tasklist',shell=True,
    # stdout=subprocess.PIPE,
    # stderr=subprocess.PIPE)
    # print(obj) # <subprocess.Popen object at 0x0000015B62E23F08>
    # print(obj.stdout) # <_io.BufferedReader name=3>
    # print(obj.stdout.read()) # 读值
    # print('>>:主')

    # import subprocess,time
    # obj=subprocess.Popen('tasklist',shell=True,
    # stdout=subprocess.PIPE,
    # stderr=subprocess.PIPE)
    # print('第一次',obj.stdout.read())
    # print('第二次',obj.stdout.read())
    # print('>>:主')

    # import subprocess,time
    # obj=subprocess.Popen('tasklist',shell=True,
    # stdout=subprocess.PIPE,
    # stderr=subprocess.PIPE)
    # # print(obj.stdout.read()) # b' xd3xb3xcfxf1xc3xfbxb3xc6...
    # print(obj.stdout.read().decode('gbk'))

    # import subprocess,time
    # obj=subprocess.Popen('tasklovelist',shell=True,
    # stdout=subprocess.PIPE,
    # stderr=subprocess.PIPE)
    # print(obj.stdout.read()) # b''
    # print(obj.stderr.read().decode('gbk'))
    '''
    'tasklovelist' 不是内部或外部命令,也不是可运行的程序
    或批处理文件。
    '''
    # import subprocess
    # obj=subprocess.Popen('tasklist|findstr python',shell=True,
    # stdout=subprocess.PIPE,
    # stderr=subprocess.PIPE)
    # print(obj.stdout.read())
    # print(obj.stderr.read().decode('gbk'))
    #
    # import subprocess
    #
    # obj1=subprocess.Popen('tasklist',shell=True,
    # stdout=subprocess.PIPE,
    # stderr=subprocess.PIPE)
    #
    # obj2=subprocess.Popen('findstr python',shell=True,
    # stdin=obj1.stdout,
    # stdout=subprocess.PIPE,
    # stderr=subprocess.PIPE)
    #
    # print(obj2.stdout.read())
    # print(obj2.stderr.read().decode('gbk'))
    '''
    b'python.exe 15244 Console 1 10,652 K '

    b'python.exe 15244 Console 1 10,704 K '
    '''
  • 相关阅读:
    原生js片段
    IE 怪异模式(Quirks Mode)对 HTML 页面的影响
    CSS3 @font-face 的使用
    css面试题——九宫格
    一些前端冷知识
    利用 document.domain 在当前的域名或者基础域名 实现跨域
    JS 判断浏览器客户端类型(ipad,iphone,android)
    防止网站被iframe调用
    doctype 的各种声明
    JQUERY中的事件处理:RETURN FALSE、阻止默认行为、阻止冒泡以及兼容性问题
  • 原文地址:https://www.cnblogs.com/0B0S/p/12061383.html
Copyright © 2020-2023  润新知