在我的 Nodejs 12.16.x 应用程序中,JWT 令牌生成如下:
const token = jwt.sign(
{
uid: this.id,
did: this.device_id,
},
process.env.jwtPrivateKey, //<<==here is the private key
{
expiresIn: (parseInt(process.env.jwt_token_expire_days) * 24).toString() + 'h',
algorithm: 'HS256' //<<==here is the algorithm
}
);
我可以用来为 JWT 令牌生成公钥/私钥的公钥/私钥生成器是什么?有人推荐ssh-keygen
。我应该为算法 HS256
选择多少位?
另外,如果已经给定了私钥,如何找到与其关联的公钥?