Redirect output to a file with dd

gpg

echo "string" | dd of=filename

click the source code to copy install gpg on any operating system with command-not-found.com