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'\r\n\xd3\xb3\xcf\xf1\xc3\xfb\xb3\xc6...
# 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\r\n'

b'python.exe 15244 Console 1 10,704 K\r\n'
'''

猜你喜欢

转载自www.cnblogs.com/0B0S/p/12061383.html