I use Mac and sometimes I use GPGTools to do the following:
- open the TextEdit application and write, let's say, "Hello World" there.
- select "Hello World" and control-click the selection, to open a context menu.
- in the context menu, select "Services > OpenPGP: Encrypt Selection to New Window" and select the recipients in the dialog box that appears.
Then a new window pops up, showing an encrypted message that looks like this:
-----BEGIN PGP MESSAGE-----
hQEMA0cwf/w1ZfpTAQf/Ze9lwDIlewAHXz2t7UgM/CJGB1E1UCHejJF21nSunztI
yf7LRMxb20VvXa6VbrzgObBrlgHS9noKCmgS9CtdXMf1owjXUbZjmFmXlIfxQnuR
**[...]**
Wuqxb83MWOBVzZ2fXKettmb39NfMBR9zEPICiMd48DBvUlR3l3aaptusjRYr865B
9em2G3bK050Y/rT3Dz6WhqNT9m70ePXefM49sjruUPrQwLi9yS+CcV4dfayBgCQD
iT5be+E=
=jqRq
-----END PGP MESSAGE-----
I would like to be able to do the same thing using the command line. And I would like to know how to do that in a way that is independent of the operating system. The solution should work in Windows and Linux too.
I know that GPGTools is based on GPG (GnuPG) and, therefore, I would assume that it should be possible to achieve what I want using the "gpg" command line tool. I know how to use "gpg" to encrypt, for instance, a "file.txt" file and obtain an encrypted "file.txt.gpg" file, but this encrypted file doesn't contain a "PGP MESSAGE" as shown above.
In summary, my question is: how can I encrypt a text string (not a file) and obtain a "PGP MESSAGE", using the command line?