Converting .asc back to .gpg
Asked Answered
C

2

11

I normally wouldn't ask but I can't find the answer on SO or google.

I'm using a library that accepts base64 encoded pgp public keys in string format. However, one of the components I need to convert has a key in .asc format. How can I convert it back to binary-pgp or base64-gp.

Sorry if it's really dumb question, I'm new to the pgp toolsets.

Thanks a lot!

Shane

Cacka answered 16/1, 2017 at 12:15 Comment(0)
C
17

Turns out it's really simple:

gpg --dearmor file.asc

Source: https://lists.gnupg.org/pipermail/gnupg-devel/2011-October/026253.html

Cacka answered 16/1, 2017 at 15:14 Comment(2)
Note quite: it's either gpg --dearmor file.asc and the de-armored output will be in file.asc.gpg or gpg --dearmor < file.asc > file.gpg which reads and writes from/to stdin.Hearthstone
@Hearthstone careful with the last one: if gpg fail (or command doesn't exist), file.gpg will still be created, with a size of 0.Cleaner
C
10

If you want to avoid a final filename of .asc.gpg, you can use the -o option of gpg, like so:

gpg -o foobar.gpg --dearmor foobar.asc

(I don't recommend using gpg --dearmor < file.asc > file.gpg because if gpg fail or does not exist, file.gpg will still be created (empty file), which lead to unwanted side effect when working with automation).

Cleaner answered 19/7, 2022 at 9:43 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.