当前位置:网站首页>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什么时候过期
边栏推荐
- ARM指令集之Load/Store指令寻址方式(二)
- K52. Chapter 1: installing kubernetes v1.22 based on kubeadm -- cluster deployment
- Design of tablewithpage
- The second day of QML study
- How to select standard products and non-standard products, the importance of selection, and how to layout the store
- 6.6 rl:mdp and reward function
- Byte order (network / host) conversion
- Pseudo instruction of arm instruction set
- Ficusjs series (I) introduction to ficusjs
- TinyMCE realizes automatic uploading of pasted pictures
猜你喜欢

创建Servlet项目

Node crawler puppeter usage

Deep learning and CV tutorial (14) | image segmentation (FCN, segnet, u-net, pspnet, deeplab, refinenet)

LeetCode 1037. Effective boomerang (vector cross product)

JS to load and display Excel files

Create servlet project

MySQL - built in function

IP address management

Must do skill -- use ffmpeg command to quickly and accurately cut video

Asynchronous path processing
随机推荐
LeetCode_字符串_简单_344.反转字符串
[QNX hypervisor 2.2 user manual] 4.1 method of building QNX hypervisor system
Channel shuffle class
PDSCH related
Lambda and filter, List 和 numpy array的索引,以及各种距离指标distance-metrics,拼接数组以及axis=0 and axis=1的区分
Promise controls the number of concurrent requests
Longest string without duplicate characters (leetcode 3)
【QNX Hypervisor 2.2 用户手册】4 构建QNX Hypervisor系统
QML学习 第一天
K53. Chapter 2 installing kubernetes v1.22 based on binary packages -- cluster deployment
ARM指令集之杂类指令
Rich text editor copying pictures in word documents
Inter class and intra class relations in video classification -- regularization
【深度学习基础】神经网络的学习(4)
PIP install in the CONDA environment cannot be installed into the specified CONDA environment (the default PIP installation location of the CONDA environment)
标品和非标品如何选品,选品的重要性,店铺怎样布局
Spark common encapsulation classes
IP address management
TinyMCE series (II) TinyMCE plug-in development
Deep learning and CV tutorial (14) | image segmentation (FCN, segnet, u-net, pspnet, deeplab, refinenet)