Command line GPG decrypting using c# - passphrase?

ε祈祈猫儿з 提交于 2019-12-06 07:26:22

The property Process.StandardInput should give you a StreamWriter that you can use to provide the passphrase on standard input.

GPG on Linux has --passphrase-fd N, where N is int. If N == 0, the passphrase is read from standard input.

Not sure if the same applies on Windows but might be worth checking out.

Use --passphrase-fd 0 to get GPG to take the passphrase from stdin and then pass it in using a pipe.

echo 123456| gpg --passphrase-fd 0 -e -u user1@example.com -r user2@example.com C:\file.csc

or

gpg --passphrase-fd 0 -e -u user1@example.com -r user2@example.com --passphrase-fd 2 file.csc < password.file

Make sure you don't pass any extra spaces on stdin somehow as GPG doesn't handle those well.

I'm not sure how you can pass something on stdin on .NET, so you'll have to fill the gap there.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!