Mac::Apps::MacPGP - Interface to MacPGP 2.6.3
use Mac::Apps::MacPGP; $object = new Mac::Apps::MacPGP; #see description for the rest
MacPerl interface to MacPGP 2.6.3. Older versions WILL NOT WORK. The MIT version, MacPGP 2.6.2, does not support nearly the number of AppleEvents as does 2.6.3. For those outside the U.S., you will not be able to download the program; but there are International versions. Perhaps in the future I will add support for those. Many of the functions should work fine for those, actually, but I imagine some will not.
MacPerl 5.1.1 (released January 1997) or higher is also required because of bugs in the AppleEvents library in previous versions.
Also required is the Mac::Apps::Launch module, however, which requires MacPerl 5.1.4r4 or higher. :)
For optional parameters, MacPGP will either use the default or prompt the user. Parameters are required unless noted as optional. Exception: For the $OUTP parameter, the MacPGP default is binary but I set it to ASCII in the module, because I rarely use binary PGP files.
$OUTP
Boolean parameters take a value of 1 (true) or 0 (false). Filenames should be given the full pathname. To leave an optional parameter empty, give it a value of undef. Optional parameters will either be given the default by MacPGP or MacPGP will prompt the user for a value if necessary.
undef
For further explanation of methods and parameters, see your MacPGP 2.6.3 user guide.
If something seems seems to not work properly, try doing it directly from MacPGP before assuming it is the fault of MacPGP.pm. :-)
Encrypt. Returns encrypted text for $TYPE="ncrd".
$TYPE="ncrd"
$object->encrypt(TYPE, DOBJ, [RECV|CPAS], PASS, USID, SIGN, READ, OUTP, LATI, WRAP, ALNS, TABX, MDAL, WSRC, COPT);
One of "encr" (encrypt files), "ncrd" (encrypt data), or "cncr" (conventional encryption).
For $TYPE="encr" or "cncr", $DOBJ is either a filename or a reference to an array of filenames. For $TYPE="ncrd", $DOBJ is the data to be encrypted. If $DOBJ is empty, MacPGP will attempt to encrypt the clipboard instead.
$TYPE="encr"
"cncr"
$DOBJ
Either the name of a recipient or a reference to an array of recipients. (encr and ncrd only)
Password used for conventional encryption. Optional. (cncr only)
The password. Optional.
Name of secret key. Optional.
Sign? One of "sepa" (signature in separate file), "incl", (signature included), "omit" (omitted, don't sign). Optional.
Input format. One of "macb" (MacBinarize first), "text", (convert text to CRLF), "norm" (do nothing). Optional.
Output format. One of "bina" (8-bit binary), "asci", (ASCII-armored). Optional.
Convert text to ISO-Latin1? Boolean. Optional.
Wrap text to this many lines, between 30 and 100. 0=no wrap. Optional.
For armored files, split output into files of this line length. 0=no split. Optional.
For wrapped files, expand tabs to this many spaces, from 0 to 9. Optional.
Use "MD5 " or "SHA1" to compute message digest for file. Optional.
Wipe out source file? Boolean. Optional. (encr and cncr only)
Self-decrypting? One of "sdf" (self-decrypting) or "sdfb", (self-decrypting and binhexed). Default is neither. Optional. (cncr only)
Decrypt. Returns decrypted text for $TYPE="dcrd" and $DOBJ ne undef. Returns signatures for $TYPE="decr".
$TYPE="dcrd"
$DOBJ ne undef
$TYPE="decr"
$object->decrypt(TYPE, DOBJ, PASS, SCRE, NSIG, APL2, RECV);
One of "decr" (decrypt files), "dcrd" (decrypt data).
For $TYPE="decr", $DOBJ is either a filename or a reference to an array of filenames. For $TYPE="dcrd", $DOBJ is the data to be decrypted. If $DOBJ is empty, MacPGP will attempt to decrypt the clipboard instead. To get signatures from "dcrd" event, see "checksignresult".
Decrypt to screen instead of file? Boolean. Optional.
Do not put up bad signature alerts? Boolean. Optional.
If direct object is a separate sig file, the file the sig applies to. Optional.
File to decrypt to. Optional. (decr only)
Sign. Returns encrypted signed text for $TYPE="sigd", returns signature results for $TYPE="sign".
$TYPE="sigd"
$TYPE="sign"
$object->sign(TYPE, DOBJ, PASS, USID, SIGN, READ, OUTP, LATI, WRAP, ALNS, TABX, MDAL, STFX);
One of "sign" (sign files), "sigd" (sign data).
For $TYPE="sign", $DOBJ is either a filename or a reference to an array of filenames. For $TYPE="sigd", $DOBJ is the data to be signed. If $DOBJ is empty, MacPGP will attempt to sign the clipboard instead.
See READ in "encrypt". Optional.
See OUTP in "encrypt". Optional.
See LATI in "encrypt". Optional.
See WRAP in "encrypt". Optional.
See ALNS in "encrypt". Optional.
See TABX in "encrypt". Optional.
See MDAL in "encrypt". Optional.
Set text flag? (Esoteric option for some PGP/MIME implementations.) Boolean. Optional.
Asciify a file.
$object->asciify(DOBJ, READ, LATI, WRAP, ALNS, TABX);
Filename or reference to an array of filenames to be asciified.
Execute MacPGP command-line command.
$object->execute(DOBJ, PASS, LATI, WRAP, ALNS, TABX, MDAL);
Command to be executed (i.e., pgp -kv pudge).
pgp -kv pudge
Generate new public/secret key pair.
$object->generate(DOBJ, LENG, EBIT);
User id of new key.
Bit length of key. Higher is stronger and slower. Lower is faster and less secure. Can be either a number from 384 to 2048, or one of the following: "casu" (casual, 512), "comm" (commercial, 768), "mili" (military, 1024). Default is casual. Optional.
Number of bits in encryption exponent. Default is 17. Optional.
Extract (export) a key.
$object->extract(DOBJ, RECV, KEYR, OUTP);
Key id to extract.
File to extract key to. File must already exist (for now). See "create".
Filename of keyring to perform operation on. Optional.
Miscellaneous keyring functions.
$object->keyring(TYPE, DOBJ, KEYR, USID);
Add key in file $DOBJ.
Count keys matching $DOBJ.
Certify key matching $DOBJ.
Return fingerprint of key matching $DOBJ.
Remove key matching $DOBJ.
Show dialog box, with text $DOBJ, of keys available in keyring. Returns user id of selected key.
Varies; see above.
Name of secret key to certify with. Optional. (crfy only)
Create temporary scratch file. File with same name, if existing, is erased.
$object->create(DOBJ);
New filename.
Copy Clipboard to file.
$object->clip2file(DOBJ);
Filename of destination file.
Copy file to Clipboard. NOTE: This only works if MacPGP is the front application (see "switchapp").
$object->file2clip(DOBJ);
Filename of source file.
Check signature result from previous decrypt data event. See "decrypt".
$object->checksignresult;
Returns error message from previous MacPGP Apple Event.
$object->getlasterror;
Returns MacPGP version.
$object->getversion;
Show/hide window.
$object->window(DOBJ);
Either "show" or "hide".
Echo PGP messages to a logfile. If logging was active when true sent or no filename is given, returns error. If logging was active. Returns full pathname if successful.
$object->logfile(DOBJ, RECV);
Logging? Boolean.
Full pathname of logfile. Existing file of same name erased. Optional.
Set up window handling. Whenever another method is called, MacPGP.pm will use these two variables to determine what app should be in front. Note: when muliple methods are called, this doesn't seem to work great. Oh well. Maybe someone else will fix this for me or have some ideas. Until then, I suggest that if you DO want MacPGP to come to the front and you have sveral methods being called one after the other, that you just set $object-switchapp(1)> and don't have it switch back.
$object-
$object->switchapp(SWITCH, APP);
Switch to MacPGP when method is called? Boolean.
Switch to $APP after $object is destroyed (i.e., when last reference to $object is made). If left blank and $SWITCH=1, MacPGP will go to front and stay there.
$APP
$object
$SWITCH=1
Returns result of parameter $DOBJ from last method call.
$object->getresults(DOBJ);
Name of parameter keyword, one of "----", "result" (synonym for "----", the direct object parameter), "errs" (error string), "errn" (error number), "outp". Optional, defaults to "result".
Returns hash of all result parameters from last method call.
%results = $object->getresultsall;
Quit MacPGP app.
$object->quitpgp;
Basic cleanup. Requires MacPerl 5.1.4r4 or better now.
Get app launching from Mac::Apps::Launch, fixed descriptor disposing.
First full release.
Added a whole slew of scripts and extensions for BBEdit, YA-NewsWatcher, Clipboard, Drag-n-Drop. See MacPGP-scripts.readme for details.
Changed the behavior of switchapp method. Switching to MacPGP only occurs when switchapp method is invoked, and switching back only occurs when object is destroyed. Previously, switching took place before and after each method call.
switchapp
Fixed bug which required decrypt, encrypt and sign to have a DOBJ value. When one of those methods is performing a function on data (dcrd, ncrd, sigd), MacPGP will use Clipboard if no data is given.
decrypt
encrypt
sign
Fixed bug in _MpgpBBool routine which would not catch unacceptable input.
_MpgpBBool
Simply switching to .tar.gz for CPAN instead of .sit.hqx.
Fixes problems in earlier release, optimizes, module-izes.
Change name from MacPGP to Mac::Apps::MacPGP.
Rewrote AppleEvent calls using individual AEPutParamDesc and AEBuild calls. Should be more efficient. Fixes other bugs (like problems with lists and certain characters in TEXT values).
AEPutParamDesc
AEBuild
Improved error handling and descriptions. Uses carp for MacPGP errors.
carp
Made file and recipients variables capable of handling either a scalar or a reference to an array.
Added switchapp, getresults, getresultsall, quitpgp methods. See docs above.
getresults
getresultsall
quitpgp
First public beta. Nearly fully-functional.
I want to benchmark different ways to switch between applications and use the best one. Stay tuned. If you have ideas, let me know.
I am investigating the idea of making this useful with other versions of MacPGP (international versions, and limited capabilities of MacPGP 2.6.2) and the future version of PGP 5.0.
I have one more method group to add, and that is for stealtifying/destealthifying files. This will come along eventually, but it is not a high priority. First I have to figure out how to use it and what it does ... :-) If you have a need/want for it, let me know.
http://www.math.ohio-state.edu/~fiedorow/PGP/
Included with the above package, take special note of the PGP User's Guide, MacPGP263_Manual, and MacPGP263_AppleEvents.
Chris Nandor <pudge@pobox.com> http://pudge.net/
Copyright (c) 1998 Chris Nandor. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Please see the Perl Artistic License.
Version 1.20 (03 January 1998)
36 POD Errors
The following errors were encountered while parsing the POD:
'=item' outside of any '=over'
You forgot a '=back' before '=head2'
You forgot a '=back' before '=head1'
To install Mac::Apps::MacPGP, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mac::Apps::MacPGP
CPAN shell
perl -MCPAN -e shell install Mac::Apps::MacPGP
For more information on module installation, please visit the detailed CPAN module installation guide.