GithubHelp home page GithubHelp logo

elecdict's Introduction

电子词典思路分析

1. 确定技术

通信 tcp通信

并发 多进程并发

数据库 mysql

2. 确定数据库

建立几个表

每个表作用和存储内容

步骤:

  • 建表

create database dict charset=utf8;

* 用户表 id name passwd
    `create table user (id int primary key auto_increment,name varchar(32) not null,passwd varchar(128) not null);`

* 历史记录 id name word time
    `create table history (id int primary key auto_increment,name varchar(32) not null,word varchar(32) not null,time varchar(64) not null);`
    
* 单词表 id word mean
    编写程序将单词本存入到数据库
    `create table words (id int primary key auto_increment,word varchar(32),mean text);`
  • 编写程序将单词本存入到数据库

    运行insert_word.py

3. 结构设计

客户端

服务端(处理数据)

4. 功能分析

客户端和服务端分别需要实现哪些功能

  • 网络模型
  • 登录
    • 客户端
      1. 输入用户名、密码
      2. 发送请求
      3. 得到回复
    • 服务端
      1. 接收请求
      2. 判断是否允许登录
      3. 反馈结果
  • 注册
    • 客户端
      1. 输入注册信息
      2. 将信息发送给服务器
      3. 等待反馈
    • 服务端
      1. 接收注册信息
      2. 验证用户是否存在
      3. 插入数据库
      4. 将信息反馈给客户端
  • 查单词
    • 客户端
      1. 输入单词
      2. 发送给服务器
      3. 获得结果
    • 服务端
      1. 接收请求
      2. 查找单词
      3. 将结果发送给客户端
      4. 插入历史记录
  • 历史记录
    • 客户端
      1. 发送请求
      2. 循环接收历史记录
    • 服务端
      1. 接收请求
      2. 查找历史记录
      3. 发送历史记录

5.协议指定

  • R name passwd 注册请求字段

  • L name passwd 登录请求字段

  • Q name word 查询单词

  • H name 查询历史记录

    cookie: import getpass passwd = getpass.getpass("secret:") 功能:隐藏输入的内容 返回值:输入的内容字符串

    cookie: 数据库 passwd的字段加密

      import hashlib
      passwd = 'abc123'
      hash = hashlib.md5() #经过md5算法生成hash对象
      hash.update(passwd.encode()) #passwd是密码的明文字节串
      hash.hexdigest() #取返回值存入到数据库
      生成'e99a18c428cb38d5f260853678922e03'
    

    cookie:加盐

    方法一:

      passwd = 'abc123'
      passwd = passwd+'awk#%&'# 加盐处理
      hash=hashlib.update(passwd.encode())
      hash.hexdigest()
      生成'fbda237579e9e018587702daf3e90982'
    

    方法二:

      passwd = 'abc123'
      hash = hashlib.md5((name+'the-salt').encode())# 加盐处理
      hash.update(passwd.encode())
      hash.hexdigest()
    

elecdict's People

Watchers

Zoe avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.