in reply to encrypt excel documents
At any rate, to do this you will need OpenSSL for Win32 (the binaries). Note: You can use whatever encryption tools you want. This example uses OpenSSL.
You will need to learn how to encrypt something with it unless you already know how or are doing it some other way.
I used:
And got an encrypted file:C:\Temp\openSSL\bin>openssl enc -aes-256-cbc -a -salt -in foo.txt -out + file.enc enter aes-256-cbc encryption password: Verifying - enter aes-256-cbc encryption password: *****
If you read the tutorial it will show you how to decrypt the file, provided the system decrypting has both the same cipher and the password (which I assume you will share your recipient via some more secure means, like the telephone).C:\Temp\openSSL\bin>type file.enc U2FsdGVkX19MZ5n8Rb41XIrAuhwtlBUPPWhbvSe4b0J3Wfj8QRRwqCxuqTG69Ta9
Now, your only 'problem' is convincing Excel to spit out a text file with the data:
use Win32::OLE; my ($filename) = "F:\\Incidents.xls"; my ($nextStep) = q|mysystem.cgi?f=incidents_show|; my ($csv) = ".\\data\\_csv\\incidents.csv"; if(-f $filename) { my(@fnStat) = stat($filename); my(@csvStat)= stat($csv); if($fnStat[9] > $csvStat[9]) { my($obj) = Win32::OLE->new("Excel.Application"); $obj->Workbooks->Open (q|F:\Incidents.xls|); if (-f q|c:\data\_csv\incidents.csv|) {unlink(q|c:\data\_csv\i +ncidents.csv|) or die "Cannot unlink the incidents.csv file!"}; $obj->ActiveWorkbook->SaveAs(q|C:\data\_csv\incidents.csv|, 6) +; $obj->ActiveWorkbook->Close(0); $obj->Quit(); "The Incident.xls file has been recently modified and the exc +el file has been created! <a href=\"$nextStep\">Click</a>"; } else { "File is okay. Proceed to CSV. <a href=\"$nextStep\">Click</a +>"; } } else { "Could not find Incidents.xls!"};
The above code checks to see whether the file on the local disk is older than the spreadsheet's last modification time. If so, it initiates the download.
Now you can shell out to OpenSSL to encrypt that file. A possible vulnerability with this method -- having a Perl script encrypt a separate file -- is that you will have to maintain the password inside of your perl script somewhere. Perhaps there is an encryption method where you wouldn't need a shared password, like PGP? I'm not sure. Try Google. Update: Here is some more on passwords with OpenSSL
Celebrate Intellectual Diversity
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: encrypt excel documents
by Win (Novice) on Aug 30, 2005 at 15:53 UTC | |
by 5mi11er (Deacon) on Aug 30, 2005 at 18:47 UTC |