当前位置:网站首页>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什么时候过期
边栏推荐
- Reentrantlock source code analysis
- Cookie和Session
- Create servlet project
- 邻居子系统之ARP协议数据处理过程
- 6.6 分离卷积
- LeetCode 890. 查找和替换模式(模拟+双哈希表)
- Promise controls the number of concurrent requests
- LeetCode_字符串_简单_344.反转字符串
- PIP install in the CONDA environment cannot be installed into the specified CONDA environment (the default PIP installation location of the CONDA environment)
- B.刷墙(C语言)
猜你喜欢

無重複字符的最長字符串(LeetCode 3)

QT based travel query and simulation system

6.6 分离卷积

LeetCode 890. Find and replace mode (analog + double hash table)

Logrotate log rotation method create and copyruncate principles

MySQL - built in function

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

寻找两个有序数组的中位数(LeetCode 4)

mysql复习

A.前缀极差
随机推荐
【QNX Hypervisor 2.2 用户手册】4 构建QNX Hypervisor系统
TinyMCE realizes automatic uploading of pasted pictures
QT based travel query and simulation system
Google Earth engine (GEE) - quick land classification by kmeans clustering (double for loop quick parameter adjustment)
5G NR協議學習--TS38.211下行通道
LeetCode_二分搜索_中等_162. 寻找峰值
How to determine the relationship between home page and search? Relationship between homepage and search
ARM processor mode and register
FPGA Development - Hello_ World routine
Basic concepts of machine learning
6.6 RL:MDP及奖励函数
Longest string without duplicate characters (leetcode 3)
Design of tablewithpage
【深度学习基础】神经网络的学习(4)
6.6 分離卷積
無重複字符的最長字符串(LeetCode 3)
ARM指令集之批量Load/Store指令
视频分类的类间和类内关系——正则化
Linear model of machine learning
A.前缀极差