/ opencodehub / scripts / test-gpg.ts
swadhinbiswas # Changelog · 1/17/2026
1464862
26 lines · 694 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

import * as openpgp from 'openpgp';

async function test() {
    try {
        console.log("Generating key...");
        const { publicKey } = await openpgp.generateKey({
            type: 'ecc',
            curve: 'ed25519' as any,
            userIDs: [{ name: 'Test', email: '[email protected]' }],
        });
        console.log("Key generated.");

        console.log("Reading public key...");
        const key = await openpgp.readKey({ armoredKey: publicKey });
        console.log("Key ID:", key.getKeyID().toHex());
        console.log("Is Private:", key.isPrivate());

        console.log("Test passed.");
    } catch (e) {
        console.error("Test failed:", e);
    }
}

test();