当前位置:网站首页>MVC模式、加密、jsonwebtoken
MVC模式、加密、jsonwebtoken
2022-06-12 11:59:00 【mustang(野马)】
MVC模式、加密、jsonwebtoken
一、MVC模式(架构思想)
M:model层,主要是数据的增删改查
V:view层,主要是视图的展示
C:controller层,主要负责业务逻辑
二、加密(md5加密、sha256加密)
1.sha256加密:以一个随机字符串的形式将需要加密的字符进行加密,安全性比md5加密方式要好
2.sha256加密步骤:
1)引入加密模块
const crypto = require(‘crypto’);
2)创建sha256算法
const hash = crypto.createHash(‘sha256’);
3)需要加密的字符
hash.update(password);
4)对密码进行加密
hash.digest(‘hex’)
三、jsonwebtoken(设置长期登录状态的核心)
1.安装
cnpm install jsonwebtoken -S
2.引入
const jwt = require(“jsonwebtoken”);
3.设置token
jwt.sign(payload,秘钥,过期时间)
1)payload:相关信息
2)秘钥:随机字符
3)过期时间:token什么时候过期
边栏推荐
- Design of virtual scrolling list
- Doris记录服务接口调用情况
- Promise controls the number of concurrent requests
- Automatic generation of folder directory structure
- Reprint --win10 open the task manager to solve the blue screen problem
- 创建Servlet项目
- 一个人必须不停地写作,才能不被茫茫人海淹没。
- How to operate the newly revised Taobao merchants and what should be paid attention to
- Rich text editor copying pictures in word documents
- [cf1392d] D. Omkar and bed Wars
猜你喜欢

6.6 rl:mdp and reward function

必杀技--使用FFmpeg命令快速精准剪切视频

Byte order - how to judge the big end and the small end

conda环境下pip install 无法安装到指定conda环境中(conda环境的默认pip安装位置)

无重复字符的最长字符串(LeetCode 3)

Chaîne la plus longue sans caractères dupliqués (leetcode 3)

PDSCH related

6.6 分离卷积

QT adds a summary of the problems encountered in the QObject class (you want to use signals and slots) and solves them in person. Error: undefined reference to `vtable for xxxxx (your class name)‘

Socket implements TCP communication flow
随机推荐
B.刷墙(C语言)
Face recognition PIP failed to install Dlib Library
How to select standard products and non-standard products, the importance of selection, and how to layout the store
Design of secure chat tool based on C #
Tpage design
Ficusjs series (I) introduction to ficusjs
机器学习之线性模型
Blue Bridge Cup 2015 CA provincial competition (filling the pit)
6.6 分离卷积
Video JS library uses custom components
A.前缀极差
One must keep writing, so as not to be submerged by the vast crowd.
Socket implements TCP communication flow
ARM指令集之乘法指令
[cf1392d] D. Omkar and bed Wars
为什么新品发布上架之后会没有流量,新品应该怎么发布?
LeetCode 890. 查找和替换模式(模拟+双哈希表)
無重複字符的最長字符串(LeetCode 3)
LeetCode_二分搜索_中等_162. 寻找峰值
Chapter VI data type (V)