-
公钥私钥的生成环境
- 在mac上面可以直接使用openssl
- 在Windows上面cmd无法使用openssl,但git bash上可以使用openssl
-
生成公钥私钥的方法
- 在git bash中输入openssl打开openssl交互式工具
- 生成私钥:genrsa -out private.key 1024(genrsa表示非对称加密,-out表示导出私钥,private.key表示私钥名称,1024表示私钥长度)

c. 通过私钥生成公钥:rsa -in private.key -pubout -out public.key

-
node中引入jwt:npm i jsonwebtoken
-
使用jwt生成token
const jwt = require('jsonwebtoken')//引入jwt
const { PRIVATE_KEY } = require('./../app/config')
class AuthController {
async login(ctx,next){
const { id, name } = ctx.user

最低0.47元/天 解锁文章
4459

被折叠的 条评论
为什么被折叠?



