NAME
MacPGP.pm
SYNOPSIS
use Mac::Apps::MacPGP;
$macpgp = new MacPGP;
DESCRIPTION
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 Japanese and International versions. Perhaps in the future I will add support for those. Many of the functions should work fine for those, actually, but imagine some will not.
MacPerl 5.1.1 (released January 1997) is also required because of bugs in the AppleEvents library in previous versions.
NOTES
For optional parameters, MacPGP will either use the default or prompt the user. Parameters are required unless noted as optional. For further explanation of methods and parameters, see your MacPGP 2.6.3 user guide.
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 ''. Optional parameters will either be given the default by MacPGP or MacPGP will prompt the user for a value if necessary. For the 'outp' parameter, the MacPGP default is binary but I set it to ASCII in the module.
If something seems seems to not work properly, try doing it directly from MacPGP before assuming it is the fault of MacPGP.pm. :)
USAGE
encrypt
Encrypt. Returns encrypted text for $type = 'ncrd'.
$macpgp->encrypt($type, $dObj, [$recv|$cpas], $pass, $usid, $sign, $read, $outp, $lati, $wrap, $alns, $tabx, $mdal, $wsrc, $copt);
- $type
-
One of 'encr' (encrypt files), 'ncrd' (encrypt data), or 'cncr' (conventional encryption).
- $dObj
-
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.
- $recv
-
Either the name of a recipient or a reference to an array of recipients. (encr and ncrd only)
- $cpas
-
Password used for conventional encryption. Optional. (cncr only)
- $pass
-
The password. Optional.
- $usid
-
Name of secret key. Optional.
- $sign
-
Sign? One of 'sepa' (signature in separate file), 'incl', (signature included), 'omit' (omitted, don't sign). Optional.
- $read
-
Input format. One of 'macb' (MacBinarize first), 'text', (convert text to CRLF), 'norm' (do nothing). Optional.
- $outp
-
Output format. One of 'bina' (8-bit binary), 'asci', (ASCII-armored). Optional.
- $lati
-
Convert text to ISO-Latin1? Boolean. Optional.
- $wrap
-
Wrap text to this many lines, between 30 and 100. 0=no wrap. Optional.
- $alns
-
For armored files, split output into files of this line length. 0=no split. Optional.
- $tabx
-
For wrapped files, expand tabs to this many spaces, from 0 to 9. Optional.
- $mdal
-
Use 'MD5 ' or 'SHA1' to compute message digest for file. Optional.
- $wsrc
-
Wipe out source file? Boolean. Optional. (encr and cncr only)
- $copt
-
Self-decrypting? One of 'sdf' (self-decrypting) or 'sdfb', (self-decrypting and binhexed). Default is neither. Optional. (cncr only)
decrypt
Decrypt. Returns decrypted text for $type = 'dcrd' and $dObj ne ''. Returns signatures for $type = 'decr'.
$macpgp->decrypt($type, $dObj, $pass, $scre, $nsig, $apl2, $recv);
- $type
-
One of 'decr' (decrypt files), 'dcrd' (decrypt data).
- $dObj
-
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".
- $pass
-
The password. Optional.
- $scre
-
Decrypt to screen instead of file? Boolean. Optional.
- $nsig
-
Do not put up bad signature alerts? Boolean. Optional.
- $apl2
-
If direct object is a separate sig file, the file the sig applies to. Optional.
- $recv
-
File to decrypt to. Optional. (decr only)
sign
Sign. Returns encrypted signed text for $type = 'sigd', returns signature results for $type = 'sign'.
$macpgp->sign($type, $dObj, $pass, $usid, $sign, $read, $outp, $lati, $wrap, $alns, $tabx, $mdal, $stfx);
- $type
-
One of 'sign' (sign files), 'sigd' (sign data).
- $dObj
-
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.
- $pass
-
The password. Optional.
- $usid
-
Name of secret key. Optional.
- $sign
-
Sign? One of 'sepa' (signature in separate file), 'incl', (signature included), 'omit' (omitted, don't sign). Optional.
- $read
-
See $read in "encrypt". Optional.
- $outp
-
See $outp in "encrypt". Optional.
- $lati
-
See $lati in "encrypt". Optional.
- $wrap
-
See $wrap in "encrypt". Optional.
- $alns
-
See $alns in "encrypt". Optional.
- $tabx
-
See $tabx in "encrypt". Optional.
- $mdal
-
See $mdal in "encrypt". Optional.
- $stfx
-
Set text flag? (Esoteric option for some PGP/MIME implementations.) Boolean. Optional.
asciify
Asciify a file.
$macpgp->asciify($dObj, $read, $lati, $wrap, $alns, $tabx);
- $dObj
-
Filename or reference to an array of filenames to be asciified.
- $read
-
See $read in "encrypt". Optional.
- $lati
-
See $lati in "encrypt". Optional.
- $wrap
-
See $wrap in "encrypt". Optional.
- $alns
-
See $alns in "encrypt". Optional.
- $tabx
-
See $tabx in "encrypt". Optional.
execute
Execute MacPGP command-line command.
$macpgp->execute($dObj, $pass, $lati, $wrap, $alns, $tabx, $mdal);
- $dObj
-
Command to be executed (i.e., 'pgp -kv pudge').
- $pass
-
The password. Optional.
- $lati
-
See $lati in "encrypt". Optional.
- $wrap
-
See $wrap in "encrypt". Optional.
- $alns
-
See $alns in "encrypt". Optional.
- $tabx
-
See $tabx in "encrypt". Optional.
- $mdal
-
See $mdal in "encrypt". Optional.
generate
Generate new public/secret key pair.
$macpgp->generate($dObj, $leng, $ebit);
- $dObj
-
User id of new key.
- $leng
-
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.
- $ebit
-
Number of bits in encryption exponent. Default is 17. Optional.
extract
Extract (export) a key.
$macpgp->extract($dObj, $recv, $keyr, $outp);
- $dObj
-
Key id to extract.
- $recv
-
File to extract key to. File must already exist (I think this is a MacPGP bug, but maybe I'm just an idiot)! See "create".
- $keyr
-
Filename of keyring to perform operation on. Optional.
- $outp
-
Output format. One of 'bina' (8-bit binary), 'asci', (ASCII-armored). Optional.
keyring
Miscellaneous keyring functions.
$macpgp->keyring($type, $dObj, $keyr, $usid);
- $type
-
- addk
-
Add key in file $dObj.
- ckey
-
Count keys matching $dObj.
- crfy
-
Certify key matching $dObj.
- fing
-
Return fingerprint of key matching $dObj.
- remv
-
Remove key matching $dObj.
- selk
-
Show dialog box, with text $dObj, of keys available in keyring. Returns key id of selected key.
- $dObj
-
Varies; see above.
- $keyr
-
Filename of keyring to perform operation on. Optional.
- $usid
-
Name of secret key to certify with. Optional. (crfy only)
create
Create temporary scratch file. File with same name, if existing, is erased.
$macpgp->create($dObj);
clip2file
Copy Clipboard to file.
$macpgp->clip2file($dObj);
file2clip
Copy file to Clipboard. NOTE: This only seems to work if MacPGP is the front application (see "switchapp").
$macpgp->file2clip($dObj);
checksignresult
Check signature result from previous $macpgp->decrypt('dcrd').
$macpgp->checksignresult;
getlasterror
Returns error message from previous MacPGP Apple Event.
$macpgp->getlasterror;
getversion
Returns MacPGP version.
$macpgp->getversion;
window
Show/hide window.
$macpgp->window($dObj);
logfile
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.
$macpgp->logfile($dObj, $recv);
- $dObj
-
Logging? Boolean.
- $recv
-
Full pathname of logfile. Existing file of same name erased. Optional.
switchapp
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 $macpgp->switchapp(1) and don't have it switch back.
$macpgp->switchapp($switch, $app);
- $switch
-
Switch to MacPGP when method is run? Boolean.
- $app
-
Switch to $app after method is finished. If left blank and $switch = 1, MacPGP will go to front and stay there.
getresults
Returns result of parameter $dObj from last method call.
$macpgp->getresults($dObj);
- $dObj
-
Name of parameter keyword, one of '----', 'result' (synonym for '----', the direct object parameter), 'errs' (error string), 'errn' (error number), 'outp', 'kyid'. Optional, defaults to 'result'.
getresultsall
Returns hash of all result parameters froim last method call.
%results = $macpgp->getresultsall;
quitpgp
Quit MacPGP app.
$macpgp->quitpgp;
VERSION NOTES
- v.1.0b3, January 15, 1997
-
Simply switching to .tar.gz for CPAN instead of .sit.hqx.
- v.1.0b2 January 8, 1997
-
Second release. Fixes problems in earlier release, optimizes, module-izes.
Change name from MacPGP to Mac::Apps::MacPGP.
Rewrote AppleEvent calls using individual
AEPutParamDesc
andAEBuild
calls. Should be more efficient. Fixes other bugs (like problems with lists and certain characters in TEXT values).Improved error handling and descriptions. Uses
carp
for MacPGP errors.Made file and recipients variables capable of handling either one scalar or a reference to an array.
Added
switchapp()
,getresults()
,getresultsall
,quitpgp
methods. See docs above.
- v.1.0b1, January 3, 1997
-
First release. Nearly fully-functional.
BUGS / TO DO
- other versions
-
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.
- stealthify
-
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 ... :-)
SEE ALSO
- MacPGP 2.6.3 Home Page
-
http://www.math.ohio-state.edu/~fiedorow/PGP/
- MacPGP 2.6.3 Documentation
-
Included with the above package, take special note of the PGP User's Guide, MacPGP263_Manual, and MacPGP263_AppleEvents.
AUTHOR / COPYRIGHT
Chris Nandor, 08-Jan-1996
mailto:pudge@pobox.com
http://pudge.net/
Copyright (c) 1997 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.
6 POD Errors
The following errors were encountered while parsing the POD:
- Around line 1086:
'=item' outside of any '=over'
- Around line 1122:
You forgot a '=back' before '=head1'
- Around line 1124:
'=item' outside of any '=over'
- Around line 1132:
You forgot a '=back' before '=head1'
- Around line 1134:
'=item' outside of any '=over'
- Around line 1142:
You forgot a '=back' before '=head1'