I can reliably convert gpg4win's ascii to binary using Notepad++ option "Base64 Decode" (credit: James K Polk). Works every time.

But when I attempt the reverse, i.e. convert binary to ascii, it works sometimes and does not work other times. Here's how I'm doing it:

  • Open the binary file in Notepad++ and select "Base64 Encode".
  • Manually add the BEGIN/END PGP message lines (-----BEGIN PGP MESSAGE-----)

This works sometimes (i.e. gpg4win can decrypt the resulting file), but fails other times (gpg4win can't decrypt). I am careful to do it exactly the same way each time, making sure there are no white spaces, etc. But it only works sometimes.

How can I get it to work using Notepad++?

Note: I can do the conversion using --enarmor, but I would like to be able to do it with Notepad++. Especially since I can get it to work sometimes, so I know it's possible, and maybe I'm missing a small piece.

  • 1
    With this approach I think you are having difficulties with characters that Notepad++ understands as end-of-line. I don't think this is viable.
    – harrymc
    Nov 14, 2018 at 17:25
  • 1
    I don't have access to a windows environment so I can't test gpg4win or Notepad++. However, using gpg I have verified that 1) gpg ignores whitespace except that the -----BEGIN PGP MESSAGE----- must end in a newline and the -----END PGP MESSAGE----- must be preceded by a newline. 2) You don't need a comment line, but if you do have one it must be terminated by a newline. 3) You don't need a checksum line, but if you have one it must be preceded by a newline and it must be the correct checksum. Nov 14, 2018 at 21:01
  • @james-k-polk. Hi James, I could get certutil and even openssl to work (had to add the BEGIN/END lines manually), but Notepad++ doesn't work for encoding. It's works every time for decoding though.
    – get_going
    Nov 15, 2018 at 0:21

1 Answer 1


Notepad++ is an editor for text files, which are files that end with special binary characters that denote an end-of-line. It will always think that your text-line is found between two end-of-line characters, and will mostly ignore the end-of-line itself in its operations.

This has the potential to destroy the file when converting to Base64, since Notepad++ will convert the text between the end-of-lines, but may cause a problem with not correctly handling the end-of-lines.

In fact, it's pretty amazing for me that this has worked correctly for you for some files, and I can readily understand that it didn't for others.

I think you should really look for another solution than Notepad++ for converting to Base64.

  • After some more attempts I found something interesting. If I decrypt the Base64 encoded file, I get an error (i.imgur.com/jcD4n1b.jpg). BUT, If I copy the contents of the file directly into gpg4win's notepad, it works.
    – get_going
    Nov 14, 2018 at 19:34
  • You found a method of circumventing the end-of-line problem? I don't know gpg4win so cannot explain why it works.
    – harrymc
    Nov 14, 2018 at 20:26
  • No I didn't. I just described what I observed, i.e. if I open the Base64 encoded file and copy the contents to gpg4win's notepad, it can decrypt. So I know Notepad++ is doing something right. But if I ask gpg4win to decrypt the file itself, it fails. What reliable alternative you can recommend on Windows?
    – get_going
    Nov 14, 2018 at 20:30
  • 2
    Microsoft#s certutil can do that (and much more), see this answer for a description. There are many others floating around like this one.
    – harrymc
    Nov 14, 2018 at 20:39
  • 1
    I agree with this answer. Without thorough investigation, you could say that opening a binary file in a text editor and using a plug-in that expects ascii input is an unreliable solution. I would use gpg --enarmor. certutil generates -----BEGIN CERTIFICATE----- which will prevent gpg from working.
    – evpo
    Nov 15, 2018 at 2:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .