Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For loading key with phrase look at <a href="https://www.dlitz.net/software/pycrypto/api/current/Crypto.PublicKey.RSA-module.html" rel="nofollow">description of Module RSA</a></p> <blockquote> <h2>Description of importKey</h2> <p><code>importKey(externKey, passphrase=None)</code></p> <p>Import an RSA key (public or private half), encoded in standard form.</p> <p>See RSAImplementation.importKey.</p> <h3>Parameters:</h3> <ul> <li><p><strong>externKey</strong> (string) - The RSA key to import, encoded as a string.</p> <p>An RSA public key can be in any of the following formats:</p> <ul> <li>X.509 subjectPublicKeyInfo DER SEQUENCE (binary or PEM encoding)</li> <li>PKCS#1 RSAPublicKey DER SEQUENCE (binary or PEM encoding)</li> <li>OpenSSH (textual public key only)</li> </ul> <p>An RSA private key can be in any of the following formats:</p> <ul> <li>PKCS#1 RSAPrivateKey DER SEQUENCE (binary or PEM encoding)</li> <li>PKCS#8 PrivateKeyInfo DER SEQUENCE (binary or PEM encoding)</li> <li>OpenSSH (textual public key only)</li> </ul> <p>For details about the PEM encoding, see RFC1421/RFC1423.</p> <p>In case of PEM encoding, the private key can be encrypted with DES or 3TDES according to a certain pass phrase. Only OpenSSL-compatible pass phrases are supported.</p></li> <li><p><strong>passphrase</strong> (string) - In case of an encrypted PEM key, this is the pass phrase from which the encryption key is derived.</p></li> </ul> <h3>Returns:</h3> <p>An RSA key object (_RSAobj).</p> <h3>Raises:</h3> <ul> <li><strong>ValueError/IndexError/TypeError</strong> - When the given key cannot be parsed (possibly because the pass phrase is wrong).</li> </ul> </blockquote> <p>Example:</p> <pre><code>from Crypto import RSA key = RSA.generate(1024) exportedKey = key.exportKey('PEM', 'my secret', pkcs=1) </code></pre> <p>For saving key with phrase look at <a href="https://www.dlitz.net/software/pycrypto/api/current/Crypto.PublicKey.RSA._RSAobj-class.html" rel="nofollow">description of object _RSAobj</a>.</p> <blockquote> <h2>Description of exportKey</h2> <p><code>exportKey(self, format='PEM', passphrase=None, pkcs=1)</code></p> <p>Export this RSA key.</p> <h3>Parameters:</h3> <ul> <li><strong>format</strong> (string) - The format to use for wrapping the key. <ul> <li>'DER'. Binary encoding, always unencrypted.</li> <li>'PEM'. Textual encoding, done according to RFC1421/RFC1423. Unencrypted (default) or > encrypted.</li> <li>'OpenSSH'. Textual encoding, done according to OpenSSH specification. Only suitable for public keys (not private keys).</li> </ul></li> <li><strong>passphrase</strong> (string) - In case of PEM, the pass phrase to derive the encryption key from.</li> <li><p><strong>pkcs</strong> (integer) - The PKCS standard to follow for assembling the key. You have two choices:</p> <ul> <li>with 1, the public key is embedded into an X.509 SubjectPublicKeyInfo DER SEQUENCE. The private key is embedded into a PKCS#1 RSAPrivateKey DER SEQUENCE. This mode is the default.</li> <li>with 8, the private key is embedded into a PKCS#8 PrivateKeyInfo DER SEQUENCE. This mode is not available for public keys. PKCS standards are not relevant for the OpenSSH format.</li> </ul></li> </ul> <h3>Returns:</h3> <p>A byte string with the encoded public or private half.</p> <h3>Raises:</h3> <ul> <li><strong>ValueError</strong> - When the format is unknown.</li> </ul> </blockquote> <p>Example:</p> <pre><code>from Crypto.PublicKey import RSA with open("key.pem", "r") as privatekey: encryptor = RSA.importKey(privatekey, passphrase="my secret") </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload