博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
python_configparser模块、hashlib模块和subprocess模块
阅读量:3972 次
发布时间:2019-05-24

本文共 1841 字,大约阅读时间需要 6 分钟。

import configparserconfig=configparser.ConfigParser()config.read('test.ini')# 1、获取sections# print(config.sections())# 2、获取某一section下的所有options# print(config.options('section1'))# 3、获取items# print(config.items('section1'))# 4、# res=config.get('section1','user')# print(res,type(res))# res=config.getint('section1','age')# print(res,type(res))# res=config.getboolean('section1','is_admin')# print(res,type(res))
# 1、什么是哈希hash#    hash一类算法,该算法接受传入的内容,经过运算得到一串hash值#    hash值的特点:#I 只要传入的内容一样,得到的hash值必然一样#II 不能由hash值返解成内容#III 不管传入的内容有多大,只要使用的hash算法不变,得到的hash值长度是一定# 2、hash的用途# 用途1:特点II用于密码密文传输与验证# 用途2:特点I、III用于文件完整性校验# 3、如何用# import hashlib## m=hashlib.md5()# m.update('hello'.encode('utf-8'))# m.update('world'.encode('utf-8'))# res=m.hexdigest() # 'helloworld'# print(res)## m1=hashlib.md5('he'.encode('utf-8'))# m1.update('llo'.encode('utf-8'))# m1.update('w'.encode('utf-8'))# m1.update('orld'.encode('utf-8'))# res=m1.hexdigest()# 'helloworld'# print(res)# 模拟撞库# cryptograph='aee949757a2e698417463d47acac93df'# import hashlib## # 制作密码字段# passwds=[#     'alex3714',#     'alex1313',#     'alex94139413',#     'alex123456',#     '123456alex',#     'a123lex',# ]## dic={}# for p in passwds:#     res=hashlib.md5(p.encode('utf-8'))#     dic[p]=res.hexdigest()## # 模拟撞库得到密码# for k,v in dic.items():#     if v == cryptograph:#         print('撞库成功,明文密码是:%s' %k)#         break# 提升撞库的成本=>密码加盐# import hashlib## m=hashlib.md5()## m.update('天王'.encode('utf-8'))# m.update('alex3714'.encode('utf-8'))# m.update('盖地虎'.encode('utf-8'))# print(m.hexdigest())
import subprocessobj=subprocess.Popen('echo 123 ; ls / ; ls /root',shell=True,                 stdout=subprocess.PIPE,                 stderr=subprocess.PIPE,                 )# print(obj)# res=obj.stdout.read()# print(res.decode('utf-8'))err_res=obj.stderr.read()print(err_res.decode('utf-8'))

转载地址:http://xfxki.baihongyu.com/

你可能感兴趣的文章
使用 Eclipse Memory Analyzer 检测内存泄漏问题
查看>>
jQuery UI Autocomplete使用技巧(jquery autocomplete demo)
查看>>
百度搜索框代码(有下拉提示的)
查看>>
完整的前端工程师面试问题列表
查看>>
Django 中接收 URL 中的中文参数
查看>>
借助 Django 的 smart_str 和 smart_unicode 进行编码转换
查看>>
在Django中试用jQuery的Autocomplete插件,实现自动提示功能
查看>>
jquery autocomplete插件结合ajax使用demo
查看>>
修复jQuery Autocomplete下拉菜单不能左对齐的情况
查看>>
Apache + PHP + MySql windows xp 安装设置
查看>>
Windows下PHP安装配置
查看>>
Eclipse和MyEclipse集成php插件
查看>>
PHPEclipse搭建PHP开发环境
查看>>
loadrunner简介
查看>>
HP Loadrunner 11下载地址
查看>>
Linux(centos6.0)下安装Node.js以及使用
查看>>
python读写不同编码txt文件
查看>>
mysql常用操作(数据库常用操作)
查看>>
页面屏蔽backspace键
查看>>
实用javaScript技术总结:屏蔽类
查看>>