QSslKey 类

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

头: #include <QSslKey>
CMake: find_package(Qt6 REQUIRED COMPONENTS Network)
target_link_libraries(mytarget PRIVATE Qt6::Network)
qmake: QT += network

注意: 此类的所有函数 可重入 .

公共函数

QSslKey ()
QSslKey (const QByteArray & encoded , QSsl::KeyAlgorithm algorithm , QSsl::EncodingFormat encoding = QSsl::Pem, QSsl::KeyType type = QSsl::PrivateKey, const QByteArray & passPhrase = QByteArray())
QSslKey (QIODevice * device , QSsl::KeyAlgorithm algorithm , QSsl::EncodingFormat encoding = QSsl::Pem, QSsl::KeyType type = QSsl::PrivateKey, const QByteArray & passPhrase = QByteArray())
QSslKey (Qt::HANDLE handle , QSsl::KeyType type = QSsl::PrivateKey)
QSslKey (const QSslKey & other )
~QSslKey ()
QSsl::KeyAlgorithm algorithm () const
void clear ()
Qt::HANDLE handle () const
bool isNull () const
int length () const
void swap (QSslKey & other )
QByteArray toDer (const QByteArray & passPhrase = QByteArray()) const
QByteArray toPem (const QByteArray & passPhrase = QByteArray()) const
QSsl::KeyType type () const
bool operator!= (const QSslKey & other ) const
QSslKey & operator= (const QSslKey & other )
bool operator== (const QSslKey & other ) const

详细描述

QSslKey provides a simple API for managing keys.

另请参阅 QSslSocket , QSslCertificate ,和 QSslCipher .

成员函数文档编制

QSslKey:: QSslKey ()

构造 null 密钥。

另请参阅 isNull ().

QSslKey:: QSslKey (const QByteArray & encoded , QSsl::KeyAlgorithm algorithm , QSsl::EncodingFormat encoding = QSsl::Pem, QSsl::KeyType type = QSsl::PrivateKey, const QByteArray & passPhrase = QByteArray())

Constructs a QSslKey by decoding the string in the byte array encoded using a specified algorithm and encoding 格式。 type specifies whether the key is public or private.

If the key is encrypted then passPhrase is used to decrypt it.

在构造后,使用 isNull () 以校验是否 encoded contained a valid key.

QSslKey:: QSslKey ( QIODevice * device , QSsl::KeyAlgorithm algorithm , QSsl::EncodingFormat encoding = QSsl::Pem, QSsl::KeyType type = QSsl::PrivateKey, const QByteArray & passPhrase = QByteArray())

Constructs a QSslKey by reading and decoding data from a device using a specified algorithm and encoding 格式。 type specifies whether the key is public or private.

If the key is encrypted then passPhrase is used to decrypt it.

在构造后,使用 isNull () 以校验是否 device 提供有效密钥。

[explicit] QSslKey:: QSslKey ( Qt::HANDLE handle , QSsl::KeyType type = QSsl::PrivateKey)

Constructs a QSslKey from a valid native key handle . type specifies whether the key is public or private.

QSslKey will take ownership for this key and you must not free the key using the native library.

QSslKey:: QSslKey (const QSslKey & other )

Constructs an identical copy of other .

[noexcept] QSslKey:: ~QSslKey ()

销毁 QSslKey 对象。

QSsl::KeyAlgorithm QSslKey:: algorithm () const

Returns the key algorithm.

void QSslKey:: clear ()

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

另请参阅 isNull ().

Qt::HANDLE QSslKey:: handle () const

Returns a pointer to the native key handle, if there is one, else nullptr .

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

警告: 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 () const

返回 true if this is a null key; otherwise false.

另请参阅 clear ().

int QSslKey:: length () const

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

[noexcept] void QSslKey:: swap ( QSslKey & other )

Swaps this ssl key with other 。此函数非常快且从不失败。

QByteArray QSslKey:: toDer (const QByteArray & passPhrase = QByteArray()) const

Returns the key in DER encoding.

The passPhrase argument should be omitted as DER cannot be encrypted. It will be removed in a future version of Qt.

QByteArray QSslKey:: toPem (const QByteArray & passPhrase = QByteArray()) const

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 () const

返回密钥类型 (即:PublicKey 或 PrivateKey)。

bool QSslKey:: operator!= (const QSslKey & other ) const

返回 true 若此密钥不等于密钥 other ;否则返回 false .

QSslKey &QSslKey:: operator= (const QSslKey & other )

Copies the contents of other into this key, making the two keys identical.

Returns a reference to this QSslKey .

bool QSslKey:: operator== (const QSslKey & other ) const

返回 true 若此密钥等于 other ;否则返回 false .