27 lines
943 B
JavaScript
27 lines
943 B
JavaScript
var express = require('express');
|
|
var router = express.Router();
|
|
|
|
const openpgp = require('openpgp');
|
|
|
|
router.get('/', function(req, res, next) {
|
|
|
|
(async () => {
|
|
const { privateKeyArmored, publicKeyArmored, revocationCertificate } = await openpgp.generateKey({
|
|
type: 'ecc', // Type of the key, defaults to ECC
|
|
curve: 'curve25519', // ECC curve name, defaults to curve25519
|
|
userIDs: [{ name: 'Jon Doe', email: 'jon@doe.com' }], // you can pass multiple user IDs
|
|
passphrase: 'super long and hard to guess secret' // protects the private key
|
|
});
|
|
|
|
console.log(privateKeyArmored); // '-----BEGIN PGP PRIVATE KEY BLOCK ... '
|
|
console.log(publicKeyArmored); // '-----BEGIN PGP PUBLIC KEY BLOCK ... '
|
|
console.log(revocationCertificate); // '-----BEGIN PGP PUBLIC KEY BLOCK ... '
|
|
})();
|
|
|
|
|
|
|
|
res.send('respond with a resource');
|
|
});
|
|
|
|
module.exports = router;
|