I tried your example on my machine and it works like expected. The result is an additional file in the local directory named secret_file.txt.gpg
, encrypted for john@doe.com
. This confirms that your actual script is fine and there might be other issues present.
You will not see any output from the script itself, the encrypted file is generated in silence. The echo
in the last line of your program does nothing, because gpg does not generate any output if there are no problems. You should take a look at the manual of shell_exec.
If the file is not created on your machine, it might be a permission issue. If you do not call the script from the command line but from a web application, the webserver user needs the appropriate permissions on the file system to create a new file.