{
    "mode": "perldoc",
    "parameter": "Crypt::DSA::Key",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Crypt%3A%3ADSA%3A%3AKey/json",
    "generated": "2026-06-11T10:22:00Z",
    "synopsis": "use Crypt::DSA::Key;\nmy $key = Crypt::DSA::Key->new;\n$key->p($p);",
    "sections": {
        "NAME": {
            "content": "Crypt::DSA::Key - DSA key\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Crypt::DSA::Key;\nmy $key = Crypt::DSA::Key->new;\n\n$key->p($p);\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "*Crypt::DSA::Key* contains a DSA key, both the public and private portions. Subclasses of\n*Crypt::DSA::Key* implement *read* and *write* methods, such that you can store DSA keys on\ndisk, and read them back into your application.\n",
            "subsections": []
        },
        "USAGE": {
            "content": "Any of the key attributes can be accessed through combination get/set methods. The key\nattributes are: *p*, *q*, *g*, *privkey*, and *pubkey*. For example:\n\n$key->p($p);\nmy $p2 = $key->p;\n\n$key = Crypt::DSA::Key->new(%arg)\nCreates a new (empty) key object. All of the attributes are initialized to 0.\n\nAlternately, if you provide the *Filename* parameter (see below), the key will be read in from\ndisk. If you provide the *Type* parameter (mandatory if *Filename* is provided), be aware that\nyour key will actually be blessed into a subclass of *Crypt::DSA::Key*. Specifically, it will be\nthe class implementing the specific read functionality for that type, eg.\n*Crypt::DSA::Key::PEM*.\n\nReturns the key on success, \"undef\" otherwise. (See *Password* for one reason why *new* might\nreturn \"undef\").\n\n*%arg* can contain:\n\n*   Type\n\nThe type of file where the key is stored. Currently the only option is *PEM*, which\nindicates a PEM file (optionally encrypted, ASN.1-encoded object). Support for\nreading/writing PEM files comes from *Convert::PEM*; if you don't have this module\ninstalled, the *new* method will die.\n\nThis argument is mandatory, *if* you're either reading the file from disk (ie. you provide a\n*Filename* argument) or you've specified the *Content* argument.\n\n*   Filename\n\nThe location of the file from which you'd like to read the key. Requires a *Type* argument\nso the decoder knows what type of file it is. You can't specify *Content* and *Filename* at\nthe same time.\n\n*   Content\n\nThe serialized version of the key. Requires a *Type* argument so the decoder knows how to\ndecode it. You can't specify *Content* and *Filename* at the same time.\n\n*   Password\n\nIf your key file is encrypted, you'll need to supply a passphrase to decrypt it. You can do\nthat here.\n\nIf your passphrase is incorrect, *new* will return \"undef\".\n\n$key->write(%arg)\nWrites a key (optionally) to disk, using a format that you define with the *Type* parameter.\n\nIf your *$key* object has a defined *privkey* (private key portion), the key will be written as\na DSA private key object; otherwise, it will be written out as a public key. Note that not all\nserialization mechanisms can produce public keys in this version--currently, only PEM public\nkeys are supported.\n\n*%arg* can include:\n\n*   Type\n\nThe type of file format that you wish to write. *PEM* is one example (in fact, currently,\nit's the only example).\n\nThis argument is mandatory, *unless* your *$key* object is already blessed into a subclass\n(eg. *Crypt::DSA::Key::PEM*), and you wish to write the file using the same subclass.\n\n*   Filename\n\nThe location of the file on disk where you want the key file to be written.\n\n*   Password\n\nIf you want the key file to be encrypted, provide this argument, and the ASN.1-encoded\nstring will be encrypted using the passphrase as a key.\n\n$key->size\nReturns the size of the key, in bits. This is actually the number of bits in the large prime\n*p*.\n\nAUTHOR & COPYRIGHTS\nPlease see the Crypt::DSA manpage for author, copyright, and license information.\n",
            "subsections": []
        }
    },
    "summary": "Crypt::DSA::Key - DSA key",
    "flags": [],
    "examples": [],
    "see_also": []
}