【问题标题】:Generating public private keys from openpgp从 openpgp 生成公钥私钥
【发布时间】:2022-01-13 04:45:39
【问题描述】:

我有以下代码,我正在尝试生成公私钥:

const openpgp = require("openpgp")
const generateKeyPair = async () => {
const { publicKeyArmored } = await openpgp.generateKey({
    userIds: [
        {
            name: 'Jon Smith', email: 'jon@example.com',
            comment: 'This key is for public sharing'
        }
    ],
    curve: 'ed25519',
    passphrase: 'super long and hard to guess secret',
});

console.log(publicKeyArmored);
}

但是我收到了这个错误。任何想法如何解决它:

(node:17380) UnhandledPromiseRejectionWarning: Error: Unknown option: userIds

【问题讨论】:

标签: javascript node.js openpgp openpgp.js


【解决方案1】:

publicKeyArmored 不是 openpgp.generateKey 的方法试试 publicKey。

const openpgp = require("openpgp")
const generateKeyPair = async () => {
    const { publicKey } = await openpgp.generateKey({
        curve: 'ed25519',
        userIDs: [
            {
                name: 'Jon Smith', email: 'jon@example.com',
                comment: 'This key is for public sharing'
            }
        ],
        passphrase: 'super long and hard to guess secret',
    });

    console.log(publicKey);
}

generateKeyPair()

输出---->

【讨论】:

    猜你喜欢
    • 2019-10-12
    • 1970-01-01
    • 2019-08-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-11
    • 1970-01-01
    相关资源
    最近更新 更多