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.