Files
ClassContent/项目合集/电商App/shop_backend/test/index.js
2025-02-18 08:31:38 +08:00

11 lines
441 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var NodeRSA = require('node-rsa')
//1.创建RSA对象并指定 秘钥长度
var key = new NodeRSA({ b: 512 });
key.setOptions({ encryptionScheme: 'pkcs1' });//指定加密格式
//2.生成 公钥私钥,使用 pkcs8标准pem格式
var publicPem = key.exportKey('pkcs8-public-pem');//制定输出格式
var privatePem = key.exportKey('pkcs8-private-pem');
console.log('公钥:\n',publicPem);
console.log('私钥:\n', privatePem);