Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.6.7

Request #13586 Being able to encrypt a file by passing a filename
Submitted: 2008-04-04 10:57 UTC
From: arnaud Assigned: gauthierm
Status: Closed Package: Crypt_GPG (version 0.5.0)
PHP Version: Irrelevant OS:
Roadmaps: (Not assigned)    
Comments Add Comment Add patch

Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem : 20 + 40 = ?

 [2008-04-04 10:57 UTC] arnaud (Arnaud Limbourg)
Description: ------------ The current encrypt method accepts data as a string. It would be nice to have an encryptFile (or a similar idea) method that would encrypt a whole file based on the fullpath passed to the method.


 [2008-04-04 17:05 UTC] gauthierm (Michael Gauthier)
Is this a convenience request or a memory-usage request? You can already encrypt files using $gpg->encrypt(file_get_contents('filename')). Memory use of file-based encryption could be improved with a dedicated file method. The biggest problem I have with file-based encryption is what to do with the output. Returning a string doesn't do much to improve the memory use problem, but specifying an output filename argument makes all method signatures more complicated. Specifying an output file also makes the actual method return value either the encrypted string or null. Do you have any API suggestions on how best to approach these problems?
 [2008-04-04 17:34 UTC] arnaud (Arnaud Limbourg)
I was thinking about memory usage problems. The best would be to have an output file. I would do something like $gpg = new Crypt_GPG('tmp' => '/tmp'); $result = $gpg->encryptFile($filepath); $result would be true if the encryption succeeds. I suppose an exception if the something goes really wrong, otherwise storing the message and offering a way to retrieve it. It is only viable for big files though as it does make things more complex. It could be the object of a new driver.
 [2008-04-07 05:24 UTC] gauthierm (Michael Gauthier)
What do you think of this proposed API? * array importKeyFile($filename) * void exportKeyFile($key_id, $output) * void encryptFile($key_id, $filename, $output[, $armor]) * void decryptFile($filename, $output[, $passphrase]) * boolean signFile($key_id, $filename, $output[, $passphrase[, $mode[, $armor]]]) * Crypt_GPG_Signature verifyFile($filename[, $signature]) If files are not readable or writeable an exception would be thrown. I think the memory problem can be cleanly handled internally using PHP streams rather than the specifying filenames and --output in the GPG command itself.
 [2008-09-17 04:23 UTC] gauthierm (Michael Gauthier)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on by the end of next Sunday (CET). If this was a problem with the website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. New methods in CVS are: * array importKeyFile($filename) * void|string encryptFile($filename, $encryptedFile = null, $armor = true) * void|string decryptFile($encryptedFile, $decryptedFile = null) * void|string signFile($filename, $signedFile = null, $mode = 'normal', $armor = true) * Crypt_GPG_Signature verifyFile($filename, $detachedSignature = null) Expect a new release soon!
 [2008-09-24 17:44 UTC] gauthierm (Michael Gauthier)
This feature is in the new release now.