zoukankan      html  css  js  c++  java
  • 3,31作业

    # 1、把登录与注册的密码都换成密文形式
    # import hashlib
    # def register():
    # m=hashlib.md5()
    # user=input('请输入用户名:')
    # pwd=input('请输入密码:')
    # re_pwd=input('请输入密码:')
    # if pwd==re_pwd:
    # m.update(pwd.encode('utf-8'))
    # res=m.hexdigest()
    # with open('db.txt',mode='at',encoding='utf-8')as f:
    # f.write(f'{user}:{res} ')
    # else:
    # print('两次密码不一致')
    #
    # dic={}
    # def login():
    # user = input('请输入用户名:')
    # with open('db.txt', mode='rt', encoding='utf-8')as f:
    # for line in f:
    # username,password=line.strip().strip(':')
    # dic[username]=password
    # if user in username:
    # pwd = input('请输入密码:')
    # m=hashlib.md5(pwd)
    # res=m.hexdigest
    # if res==dic[username]:
    # print('登录成功')
    # else:
    # pass
    # else:
    # pass
    # 2、文件完整性校验(考虑大文件)
    import hashlib
    def srt_file():
    with open('srt_file_txt',mode='rb')as f1:
    m=hashlib.md5()
    for i in [0,150,300]:
    f1.seek(i,0)
    res=f1.read(50)
    m.update(res)
    content=m.hexdigest
    return content

    def dst_file():
    with open('dst_file_txt',mode='rb')as f2:
    m=hashlib.md5()
    for i in [0,150,300]:
    f2.seek(i,0)
    res=f2.read(50)
    m.update(res)
    content2=m.hexdigest
    if content2==srt_file():
    print('文件一致')
    else:
    print('文件不一致')


    # 3、注册功能改用json实现
    import hashlib
    import json
    def register():
    m=hashlib.md5()
    user=input('请输入用户名:')
    pwd=input('请输入密码:')
    re_pwd=input('请输入密码:')
    if pwd==re_pwd:
    m.update(pwd.encode('utf-8'))
    res=m.hexdigest()
    with open('db.txt',mode='at',encoding='utf-8')as f:
    json.dump(f'{user}:{res} ',f)
    else:
    print('两次密码不一致')

    # 4、项目的配置文件采用configparser进行解析
  • 相关阅读:
    数据结构(二)(三)栈和队列
    数据结构(一)线性表
    中信卡笔试代码
    Jenkins搭建-简单使用
    python 生成指定两个ip间的所有ip
    形象理解 什么是磁盘碎片
    形象理解软件位宽 32位和64位的区别
    看板娘>_
    Win10一张网卡设置多个ip地址
    VMware ubuntu安装tools灰色?
  • 原文地址:https://www.cnblogs.com/haliluyafeng/p/12609600.html
Copyright © 2011-2022 走看看