• 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进行解析





  • 相关阅读:
    URL重定向功能与APS.NET的固化功能结合
    How can I share types when generate WebSevice proxies using local paths
    C# Coding Standard Naming Conventions and Style
    VS自动化对象模型
    odac 如何捕捉错误odac 如何捕捉错误
    webbrower应用实例
    webbrower在同一个窗口打开新增窗口
    [DELPHI]$2501錯誤處理
    暴力破解例子
    webbrower连接在新form中显示
  • 原文地址:https://www.cnblogs.com/chenyoupan/p/12608169.html
Copyright © 2020-2023  润新知