|  | Home · All Classes · Modules

# QSslKey Class Reference
[QtNetwork module]

The QSslKey class provides an interface for private and public keys. More...

### Methods

- __init__ (self)
- __init__ (self, QByteArray encoded, QSsl.KeyAlgorithm algorithm, QSsl.EncodingFormat format = QSsl.Pem, QSsl.KeyType type = QSsl.PrivateKey, QByteArray passPhrase = QByteArray())
- __init__ (self, QIODevice device, QSsl.KeyAlgorithm algorithm, QSsl.EncodingFormat format = QSsl.Pem, QSsl.KeyType type = QSsl.PrivateKey, QByteArray passPhrase = QByteArray())
- __init__ (self, QSslKey other)
- QSsl.KeyAlgorithm algorithm (self)
- clear (self)
- sip.voidptr handle (self)
- bool isNull (self)
- int length (self)
- QByteArray toDer (self, QByteArray passPhrase = QByteArray())
- QByteArray toPem (self, QByteArray passPhrase = QByteArray())
- QSsl.KeyType type (self)

### Special Methods

- bool __eq__ (self, QSslKey key)
- bool __ne__ (self, QSslKey key)

## Detailed Description

The QSslKey class provides an interface for private and public keys.

QSslKey provides a simple API for managing keys.

See also QSslSocket, QSslCertificate, and QSslCipher.

## Method Documentation

### QSslKey.__init__ (self)

Constructs a null key.

See also isNull().

### QSslKey.__init__ (self, QByteArray encoded, QSsl.KeyAlgorithm algorithm, QSsl.EncodingFormat format = QSsl.Pem, QSsl.KeyType type = QSsl.PrivateKey, QByteArray passPhrase = QByteArray())

Constructs a QSslKey by decoding the string in the byte array encoded using a specified algorithm and encoding format. If the encoded key is encrypted, passPhrase is used to decrypt it. type specifies whether the key is public or private.

After construction, use isNull() to check if encoded contained a valid key.

### QSslKey.__init__ (self, QIODevice device, QSsl.KeyAlgorithm algorithm, QSsl.EncodingFormat format = QSsl.Pem, QSsl.KeyType type = QSsl.PrivateKey, QByteArray passPhrase = QByteArray())

Constructs a QSslKey by reading and decoding data from a device using a specified algorithm and encoding format. If the encoded key is encrypted, passPhrase is used to decrypt it. type specifies whether the key is public or private.

After construction, use isNull() to check if device provided a valid key.

### QSslKey.__init__ (self, QSslKey other)

Constructs an identical copy of other.

### QSsl.KeyAlgorithm QSslKey.algorithm (self)

Returns the key algorithm.

### QSslKey.clear (self)

Clears the contents of this key, making it a null key.

See also isNull().

### sip.voidptr QSslKey.handle (self)

Returns a pointer to the native key handle, if it is available; otherwise a null pointer is returned.

You can use this handle together with the native API to access extended information about the key.

Warning: Use of this function has a high probability of being non-portable, and its return value may vary across platforms, and between minor Qt releases.

### bool QSslKey.isNull (self)

Returns true if this is a null key; otherwise false.

See also clear().

### int QSslKey.length (self)

Returns the length of the key in bits, or -1 if the key is null.

### QByteArray QSslKey.toDer (self, QByteArray passPhrase = QByteArray())

Returns the key in DER encoding. The result is encrypted with passPhrase if the key is a private key and passPhrase is non-empty.

### QByteArray QSslKey.toPem (self, QByteArray passPhrase = QByteArray())

Returns the key in PEM encoding. The result is encrypted with passPhrase if the key is a private key and passPhrase is non-empty.

### QSsl.KeyType QSslKey.type (self)

Returns the type of the key (i.e., PublicKey or PrivateKey).

### bool QSslKey.__eq__ (self, QSslKey key)

### bool QSslKey.__ne__ (self, QSslKey key)