How to convert a (binary) .key PGP file to an ASCII-armored file?

pgp
Bruce picture Bruce · Mar 20, 2014 · Viewed 18k times · Source

Is there a way to convert a (binary) .key file to an ASCII-armored .asc file?

There is a previous post which seems to suggest the file extension don't matter, the file content is the same: What is the difference b/w .pkr and .key file with respect to PGP?

Answer

Jens Erat picture Jens Erat · Mar 20, 2014

You can use GnuPG for this. From man gpg:

   --enarmor
   --dearmor
          Pack or unpack an arbitrary input into/from an OpenPGP ASCII armor.
          This is a GnuPG extension to OpenPGP and in general not very useful.

--enarmor reads from stdin and outputs the armored version to stdout, --dearmor works the other way round. For ASCII armoring a binary keyring, use gpg --enarmor <file.key >file.asc.

Although the two files are different, they share the same OpenPGP packets and can be converted in both directions. The ASCII-armored version was created for usage in e-mail and other plain ASCII protocols.