Crypt::PGP5 - An Object Oriented Interface to PGP5.
use Crypt::PGP5; $pgp = new Crypt::PGP5; $pgp->secretkey ($keyid); # Set ID of default secret key. $pgp->passphrase ($passphrase); # Set passphrase. $pgp->armor ($boolean); # Switch ASCII armoring on/off. $pgp->detach ($boolean); # Switch detached signatures on/off. $pgp->encryptsafe ($boolean); # Switch paranoid encryption on/off. $pgp->version ($versionstring); # Set version string. $pgp->debug ($boolean); # Switch debugging output on/off. $signed = $pgp->sign (@message); @recipients = $pgp->msginfo (@ciphertext); $ciphertext = $pgp->encrypt ([@recipients], @plaintext); ($signature, $plaintext) = $pgp->verify (@ciphertext); ($signature, $plaintext) = $pgp->dverify ([@signature], [@message]); (Most of the methods below will be encapsulated into the Crypt::PGP5::Key class by next release, bewarned!) $pgp->addkey ($keyring, @key); $pgp->delkey ($keyid); $pgp->disablekey ($keyid); $pgp->enablekey ($keyid); @keys = $pgp->keyinfo (@ids); $keystring = $pgp->extractkey ($userid, $keyring); $pgp->keypass ($keyid, $oldpasswd, $newpasswd); $status = $pgp->keygen ($name, $email, $keytype, $keysize, $expire, $pass);
The Crypt::PGP5 module provides near complete access to PGP 5 functionality through an object oriented interface. It provides methods for encryption, decryption, signing, signature verification, key generation, key export and import, and most other key management functions.
Creates and returns a new Crypt::PGP5 object.
Sets the SECRETKEY instance variable which may be a KeyID or a username. This is the ID of the default key to use for signing.
Sets the PASSPHRASE instance variable, required for signing and decryption.
Sets the ARMOR instance variable. If set to 0, Crypt::PGP5 doesn't ASCII armor its output. Else, it does. Default is to use ascii-armoring. I haven't tested this without ASCII armoring yet.
Sets the DETACH instance variable. If set to 1, the sign method will produce detached signature certificates, else it won't. The default is to produce detached signatures.
Sets the ENCRYPTSAFE instance variable. If set to 1, encryption will fail if trying to encrypt to a key which is not trusted. This is the default. Switch to 0 if you want to encrypt to untrusted keys.
Sets the VERSION instance variable which can be used to change the Version: string on the PGP output to whatever you like.
Sets the DEBUG instance variable which causes the raw output of Crypt::PGP5's interaction with the PGP binary to be dumped to STDOUT.
Signs @message with the secret key specified with secretkey () and returns the result as a string.
Verifies or decrypts the message in @message and returns the Crypt::PGP5::Signature object corresponding to the signature on the message (if any, or undef otherwise), and a string containing the decrypted message.
Verifies the detactched signature @signature on @message and returns a Crypt::PGP5::Signature object corresponding to the signature on the message, along with a string containing the plaintext message.
Returns a list of the recipient key IDs that @ciphertext is encrypted to.
Encrypts @plaintext with the public keys of the recipients listed in the arrayref passed as the first argument and returns the result in a string, or undef if there was an error while processing. Returns ciphertext if the message could be encrypted to at least one of the recipients.
Adds the keys given in $key to the user's key ring and returns a list of Crypt::PGP::Key objects corresponding to the keys that were added. If $pretend is true, it pretends to add the key and creates the key object, but doesn't actually perform the key addition.
Deletes the key with $keyid from the user's key ring.
Disables the key with $keyid.
Enables the key with $keyid.
Returns an array of Crypt::PGP5::Key objects corresponding to the keyids listed in @keyids.
Parses a raw PGP formatted key listing and returns a list of Crypt::PGP5::Key objects.
Change the passphrase for a key. Returns true if the passphrase change succeeded, false if not.
Extracts the key for $userid from $keyring and returns the result. The $keyring argument is optional and defaults to the public keyring set with pubring ().
Creates a new keypair with the parameters specified. $keytype may be one of 'RSA' or 'DSS'. $keysize can be any of 768, 1024, 2048, 3072 or 4096 for DSS keys, and 768, 1024 or 2048 for RSA type keys. Returns undef if there was an error, otherwise returns a filehandle that reports the progress of the key generation process similar to the way PGP does. The key generation is not complete till you read an EOF from the returned filehandle.
Crypt::PGP5 is Copyright (c) 1999-2000 Ashish Gulhati <firstname.lastname@example.org>. All Rights Reserved.
Thanks to Barkha for inspiration and lots of laughs; to Rex Rogers at Laissez Faire City for putting together a great environment to hack on freedom technologies; and of-course, to Phil Zimmerman, Larry Wall, Richard Stallman, and Linus Torvalds.
This code is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
It would be nice if you would mail your patches to me, and I would love to hear about projects that make use of this module.
This is free software. If it breaks, you own both parts.