Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

154
Views
OpenPGP ^5.0.0-5 use public key from hardcoded string

This is not working for me, openPGP just freezes:

import openpgp from 'openpgp';

const publicKeyArmored = `-----BEGIN PGP PUBLIC KEY BLOCK-----

xjMEYLTYzBYJKwYBBAHaRw8BAQdAoatyco6C3CO87ZxgjIfWsFv3RMxs5W1F
EinwU2UiQ+bNF3Rlc3QgPHRlc3RAZXhhbXBsZS5vcmc+wowEEBYKAB0FAmC0
2MwECwkHCAMVCAoEFgACAQIZAQIbAwIeAQAhCRC+iM+wNlG7chYhBFZgyLBQ
Cavx4mET576Iz7A2UbtyVa8BAP1oFrSwoGdd7+dgBUu7KwU02wvrtuqyURe5
GFSTyMn2AQDWTsJjgYq7hPqSQoeZ30xN0eUoiUiyIA/ffqhM2qHPD844BGC0
2MwSCisGAQQBl1UBBQEBB0CxgKqNlcBTkuaFRvYm/UbR8ZKFFda0tnUCTzl/
tgCsJgMBCAfCeAQYFggACQUCYLTYzAIbDAAhCRC+iM+wNlG7chYhBFZgyLBQ
Cavx4mET576Iz7A2UbtysPgA/0pn4n3QqBBc56/okcGFdC78LEwDLN/ZLkY6
azfQ1aqwAP0d9CWw9ywheGtB1SBCzHZbToKaltVFCNT1ArSUFK45Dg==
=pnHg
-----END PGP PUBLIC KEY BLOCK-----
`;

let messageEncrypt = await openpgp.encrypt({
    message: await openpgp.createMessage({ text: 'test' }),
    publicKeys: await openpgp.readKeys({ armoredKey: publicKeyArmored }) // This promise never resolves
});

console.log(messageEncrypt);

However, if I read the key from disk using below approach it works:

import { readFileSync } from 'fs';
import openpgp from 'openpgp';

const armoredKeys = readFileSync('./public.key.asc', {
    encoding: 'utf8',
});

let messageEncrypt = await openpgp.encrypt({
    message: await openpgp.createMessage({ text: 'test' }),
    publicKeys: await openpgp.readKeys({ armoredKey: publicKeyArmored })
});

console.log(messageEncrypt); // Totally works

Since I'm eventually retrieving the key from AWS Secrets Manager I will have to treat it as a string and not a file on disk. I've tried using \n newline in the hardcoded string key, but doesn't make any difference.

What am I missing?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!