Solaris 10 encrypt command: can't use heredocs

I'm trying to use the Solaris 10 "encrypt" command in a script. I want to encrypt a file called "database", but not using a keyfile, instead using a keyphrase. Running this from the cli requests the user to input "Enter key:" which is fair enough but I want to run this from a script. I've tried using heredocs but it doesn't work, always displaing the "Enter key:" request.

This is what I've got so far:

encrypt -a aes -i /database <<EncryptionKey
fredbloggs
EncryptionKey
chmod 400 /database

Anyone help please?

Thanks

Andy.

Why can't you use a key file? You also need a -o filename for the output file unless you are using it in a pipeline. Here is an easy way of generating a key file:

dd if=/dev/random of=/path/to/key/file bs=8 count=8