Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

Here's a linklink to a stackoverflow answer that maybe of further assistance; I have a project that does bulk decryption/encryption, and due to GnuPG being very strict about passphrases, learned the hard way that --passphrase only works on rare occasions. Instead consider the --passphrase-fd option to be more reliable.

This script makes proper use of the --passphrase -fd option, and has been tested publicly via Travis-CI where you can find logs of it in action.

Now I ain't going to just post links to an answer without providing some example code here, so here's an updated "stand alone" script you can play with:

#!/usr/bin/env bash # Set some variables for easy modding Var_fd='9' Var_pass="/path/to/passphrase.file" Var_gpg_opts="--passphrase-fd ${Var_fd} --decrypt" Var_output_location="out.txt" Arr_string=( "$@" ) # Open file descriptor and shove the passphrase file into it if [ -f "${Var_pass}" ]; then exec ${Var_fd}<"${Var_pass}" else exec ${Var_fd}<(echo "${Var_pass}") fi # Pipe input array though gpg and append to output file cat <<<"${Arr_string[*]}" | $(which gpg) ${Var_gpg_opts} >> ${Var_output_location} # Do not forget to close the file descriptor exec ${Var_fd}>&- 

While the above isn't as fancy as the linked protect at GitHub it should be even more functional than the answer linked at the beginning of this post.

Happy hacking.

Here's a link to a stackoverflow answer that maybe of further assistance; I have a project that does bulk decryption/encryption, and due to GnuPG being very strict about passphrases, learned the hard way that --passphrase only works on rare occasions. Instead consider the --passphrase-fd option to be more reliable.

This script makes proper use of the --passphrase -fd option, and has been tested publicly via Travis-CI where you can find logs of it in action.

Now I ain't going to just post links to an answer without providing some example code here, so here's an updated "stand alone" script you can play with:

#!/usr/bin/env bash # Set some variables for easy modding Var_fd='9' Var_pass="/path/to/passphrase.file" Var_gpg_opts="--passphrase-fd ${Var_fd} --decrypt" Var_output_location="out.txt" Arr_string=( "$@" ) # Open file descriptor and shove the passphrase file into it if [ -f "${Var_pass}" ]; then exec ${Var_fd}<"${Var_pass}" else exec ${Var_fd}<(echo "${Var_pass}") fi # Pipe input array though gpg and append to output file cat <<<"${Arr_string[*]}" | $(which gpg) ${Var_gpg_opts} >> ${Var_output_location} # Do not forget to close the file descriptor exec ${Var_fd}>&- 

While the above isn't as fancy as the linked protect at GitHub it should be even more functional than the answer linked at the beginning of this post.

Happy hacking.

Here's a link to a stackoverflow answer that maybe of further assistance; I have a project that does bulk decryption/encryption, and due to GnuPG being very strict about passphrases, learned the hard way that --passphrase only works on rare occasions. Instead consider the --passphrase-fd option to be more reliable.

This script makes proper use of the --passphrase -fd option, and has been tested publicly via Travis-CI where you can find logs of it in action.

Now I ain't going to just post links to an answer without providing some example code here, so here's an updated "stand alone" script you can play with:

#!/usr/bin/env bash # Set some variables for easy modding Var_fd='9' Var_pass="/path/to/passphrase.file" Var_gpg_opts="--passphrase-fd ${Var_fd} --decrypt" Var_output_location="out.txt" Arr_string=( "$@" ) # Open file descriptor and shove the passphrase file into it if [ -f "${Var_pass}" ]; then exec ${Var_fd}<"${Var_pass}" else exec ${Var_fd}<(echo "${Var_pass}") fi # Pipe input array though gpg and append to output file cat <<<"${Arr_string[*]}" | $(which gpg) ${Var_gpg_opts} >> ${Var_output_location} # Do not forget to close the file descriptor exec ${Var_fd}>&- 

While the above isn't as fancy as the linked protect at GitHub it should be even more functional than the answer linked at the beginning of this post.

Happy hacking.

Here's a link to a stackoverflowstackoverflow answer that maybe of further assistance; I have a project that does bulk decryption/encryption, and dodue to GnuPGGnuPG being very strict about passphrases had to learn, learned the hard way that --passphrasewill only workworks on rare occasions, instead. Instead consider the --passphrase-fd option to be more reliable.

TheThis script that makes proper use of the --passphrase -fd option, and has been tested publicly via Travis-CITravis-CI where you can find logs of it in action.

Now I ain't going to just post links to an answer without providing some example code here, so here's an updated "stand alone" script you can play with:

#!/usr/bin/env bash # Set some variables for easy modding Var_fd='9' Var_pass="/path/to/passphrase.file" Var_gpg_opts="--passphrase-fd ${Var_fd} --decrypt" Var_output_location="out.txt" Arr_string=( "$@" ) # Open file descriptor and shove the passphrase file into it if [ -f "${Var_pass}" ]; then exec ${Var_fd}<"${Var_pass}" else exec ${Var_fd}<(echo "${Var_pass}") fi # Pipe input array though gpg and append to output file cat <<<"${Arr_string[*]}" | $(which gpg) ${Var_gpg_opts} >> ${Var_output_location} # Do not forget to close the file descriptor exec ${Var_fd}>&- 

While the above isn't as fancy as the linked protect at GitHub it should be even more functional than the answer linked at the beginning of this post.

Happy hacking.

Here's a link to a stackoverflow answer that maybe of further assistance; I have a project that does bulk decryption/encryption and do to GnuPG being very strict about passphrases had to learn the hard way that --passphrasewill only work on rare occasions, instead consider the --passphrase-fd option to be more reliable.

The script that makes proper use of --passphrase -fd option has been tested publicly via Travis-CI where you can find logs of it in action.

Now I ain't going to just post links to an answer without providing some example code here, so here's an updated "stand alone" script you can play with

#!/usr/bin/env bash # Set some variables for easy modding Var_fd='9' Var_pass="/path/to/passphrase.file" Var_gpg_opts="--passphrase-fd ${Var_fd} --decrypt" Var_output_location="out.txt" Arr_string=( "$@" ) # Open file descriptor and shove the passphrase file into it if [ -f "${Var_pass}" ]; then exec ${Var_fd}<"${Var_pass}" else exec ${Var_fd}<(echo "${Var_pass}") fi # Pipe input array though gpg and append to output file cat <<<"${Arr_string[*]}" | $(which gpg) ${Var_gpg_opts} >> ${Var_output_location} # Do not forget to close the file descriptor exec ${Var_fd}>&- 

While the above isn't as fancy as the linked protect at GitHub it should be even more functional than the answer linked at the beginning of this post.

Happy hacking.

Here's a link to a stackoverflow answer that maybe of further assistance; I have a project that does bulk decryption/encryption, and due to GnuPG being very strict about passphrases, learned the hard way that --passphrase only works on rare occasions. Instead consider the --passphrase-fd option to be more reliable.

This script makes proper use of the --passphrase -fd option, and has been tested publicly via Travis-CI where you can find logs of it in action.

Now I ain't going to just post links to an answer without providing some example code here, so here's an updated "stand alone" script you can play with:

#!/usr/bin/env bash # Set some variables for easy modding Var_fd='9' Var_pass="/path/to/passphrase.file" Var_gpg_opts="--passphrase-fd ${Var_fd} --decrypt" Var_output_location="out.txt" Arr_string=( "$@" ) # Open file descriptor and shove the passphrase file into it if [ -f "${Var_pass}" ]; then exec ${Var_fd}<"${Var_pass}" else exec ${Var_fd}<(echo "${Var_pass}") fi # Pipe input array though gpg and append to output file cat <<<"${Arr_string[*]}" | $(which gpg) ${Var_gpg_opts} >> ${Var_output_location} # Do not forget to close the file descriptor exec ${Var_fd}>&- 

While the above isn't as fancy as the linked protect at GitHub it should be even more functional than the answer linked at the beginning of this post.

Happy hacking.

Source Link
S0AndS0
  • 466
  • 1
  • 4
  • 12

Here's a link to a stackoverflow answer that maybe of further assistance; I have a project that does bulk decryption/encryption and do to GnuPG being very strict about passphrases had to learn the hard way that --passphrasewill only work on rare occasions, instead consider the --passphrase-fd option to be more reliable.

The script that makes proper use of --passphrase -fd option has been tested publicly via Travis-CI where you can find logs of it in action.

Now I ain't going to just post links to an answer without providing some example code here, so here's an updated "stand alone" script you can play with

#!/usr/bin/env bash # Set some variables for easy modding Var_fd='9' Var_pass="/path/to/passphrase.file" Var_gpg_opts="--passphrase-fd ${Var_fd} --decrypt" Var_output_location="out.txt" Arr_string=( "$@" ) # Open file descriptor and shove the passphrase file into it if [ -f "${Var_pass}" ]; then exec ${Var_fd}<"${Var_pass}" else exec ${Var_fd}<(echo "${Var_pass}") fi # Pipe input array though gpg and append to output file cat <<<"${Arr_string[*]}" | $(which gpg) ${Var_gpg_opts} >> ${Var_output_location} # Do not forget to close the file descriptor exec ${Var_fd}>&- 

While the above isn't as fancy as the linked protect at GitHub it should be even more functional than the answer linked at the beginning of this post.

Happy hacking.