I find having to encrypt to and from a file quite a pain. I create a message
in PHP, save it to a temporary file, encrypt it to a second temporary file,
read this file, then mail the contents. If you are working with the message,
either before or after encryption, in PHP then this process clearly contains
more effort than it needs to. Also, writing the plain text message to disk
and then deleting it with the unlink, isn't all that secure.
This patch allows you to supply the message to encrypt as a string, and
allows you to get back the encrypted message as a string. Of course it is
still possible to use files if you prefer (by specifying files with the
"file://" prefix, as used by the certificate parameter). It's fairly
simple, and should probably be applied to other functions in this extension
too. If people like it, I'd be happy to do the same to these functions.
As I see it there are three potential problems with this patch:
1) Changes default behaviour (people wanting to use files would need to add
"file://" to their filenames), so would be best added at a major version.
2) Encrypting a message from memory may not be binary safe (output to memory
will always be binary safe).
3) It's my first patch, so it may not be perfect. I'm happy to accept
criticism.
Richard.