簡體   English   中英

從 openpgp 生成公鑰私鑰

[英]Generating public private keys from openpgp

我有以下代碼,我正在嘗試生成公私鑰:

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

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()

output ----> 在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM