0

I have this script which sounds like what I want to do:

cat something_so_sign.xzy | gpg \
--passphrase-file "plaintext_passphrase.txt" \
--batch \
--pinentry-mode loopback \
-bsa

which I ran in .bat and then realize this was from Linux. I got that code from here: gpg encrypt file without keyboard interaction

But now I want to do this in CMD and I've researched for hours; I can't find exactly what I want to do. Everything I research either generates a key automatically, doesn't specify a key, or requires user interaction throughout the script run (I need this automated). I also like this particular script because its simple and I understand it. But What is the CMD equivalent of this?

I don't mind using a different method either...but my powershell version on the server is old (2.0) and it would be a huge, time consuming effort to get someone to update that. So, I can't install modules in powershell. It would also not be ideal to have to download external programs. So, I'm coming back to using .bat to encrypt my file, using a key that I'll store in its own file.

PBJ
  • 354
  • 2
  • 15
  • `cat` is only a minor thing here. The main tool is `gpg`. Do you have that on your Windows machine? – DodgyCodeException Aug 22 '19 at 14:43
  • Hmmmm. I doubt it. I can't really find out because I have limited permissions and access to the servers which will be running my script. I only know that we use .bat files for a lot of jobs and that seems to be the recommendation for me....if there's a way that I can specify my encryption key stored in a separate file, using "cipher" in CMD, or someting like that...that would be great. I haven't found any such syntax anywhere. – PBJ Aug 22 '19 at 14:45
  • Oh wait...maybe that program is installed. I found another script to decrypt something which looks like this, although I don't really understand what it's doing exactly: C:\GnuPG\pub\gpg.exe --batch --yes --passphrase "blah" --output D:\dir\In\myfile.txt --decrypt D:\dir\In\New_InFile.csv.pgp TYPE D:\dir\In\myfile.txt | FIND /V "" > D:\dir\In\myfile.txt, although I want to store the password in a separate file. – PBJ Aug 22 '19 at 14:55
  • 1
    Thanks for the input, but your input actually helped me know what to research, which is helpful as I have been researching the wrong things for quite awhile now. I didn't know that there was no easier way to do what I want. So, I would argue that the question is on-topic as "a practical, answerable problem that is unique to software development" (...with enough research and time and money, we will all solve our own problems eventually and we don't need this website at all). – PBJ Aug 22 '19 at 15:36
  • I'm back...have read the GNU manuals, done more research, and I still keep coming back to my original question. I found out that my servers DO have Gnu/GPG installed. I can't understand how no one seems to have accomplished this before: encrypting a file while the key is in a separate file, from Windows, using GPG. I think since GPG is installed here, I shouldn't need to convert - right? – PBJ Aug 26 '19 at 15:17
  • Basically, instead of `cat something_so_sign.xzy | gpg ... ` do `gpg ... – DodgyCodeException Sep 07 '19 at 14:40

0 Answers0