Encrypting a file with OpenSSL in a script

I have blogged before about using openssl to encrypt files, I recently had to do this in a script, and needed a way to pass the salt password without being prompted.  My solution was to use the -pass switch and standard input.

echo <My Salt Password> | openssl enc -aes-256-cbc -md sha512 -pbkdf2 -salt -in ~/test.txt -out ~/test.txt.enc -pass stdin