PySide6.QtNetwork.QSslKey¶
- class QSslKey¶
- The - QSslKeyclass provides an interface for private and public keys. More…- Synopsis¶- Methods¶- Note - This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE - Detailed Description¶- QSslKeyprovides a simple API for managing keys.- See also - __init__()¶
 - Constructs a null key. - See also - __init__(other)
- Parameters:
- other – - QSslKey
 
 - Constructs an identical copy of - other.- __init__(handle[, type=QSsl.PrivateKey])
- Parameters:
- handle – - Qt::HANDLE
- type – - KeyType
 
 
 - Constructs a - QSslKeyfrom a valid native key- handle.- typespecifies whether the key is public or private.- QSslKeywill take ownership for this key and you must not free the key using the native library.- __init__(device, algorithm[, format=QSsl.Pem[, type=QSsl.PrivateKey[, passPhrase=QByteArray()]]])
- Parameters:
- device – - QIODevice
- algorithm – - KeyAlgorithm
- format – - EncodingFormat
- type – - KeyType
- passPhrase – - QByteArray
 
 
 - Constructs a - QSslKeyby reading and decoding data from a- deviceusing a specified- algorithmand- encodingformat.- typespecifies whether the key is public or private.- If the key is encrypted then - passPhraseis used to decrypt it.- After construction, use - isNull()to check if- deviceprovided a valid key.- __init__(encoded, algorithm[, format=QSsl.Pem[, type=QSsl.PrivateKey[, passPhrase=QByteArray()]]])
- Parameters:
- encoded – - QByteArray
- algorithm – - KeyAlgorithm
- format – - EncodingFormat
- type – - KeyType
- passPhrase – - QByteArray
 
 
 - Constructs a - QSslKeyby decoding the string in the byte array- encodedusing a specified- algorithmand- encodingformat.- typespecifies whether the key is public or private.- If the key is encrypted then - passPhraseis used to decrypt it.- After construction, use - isNull()to check if- encodedcontained a valid key.- algorithm()¶
- Return type:
 
 - Returns the key algorithm. - clear()¶
 - Clears the contents of this key, making it a null key. - See also - handle()¶
- Return type:
- Qt::HANDLE
 
 - Returns a pointer to the native key handle, if there is one, else - None.- 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. - isNull()¶
- Return type:
- bool 
 
 - Returns - trueif this is a null key; otherwise false.- See also - length()¶
- Return type:
- int 
 
 - Returns the length of the key in bits, or -1 if the key is null. - Returns - trueif this key is not equal to key- other; otherwise returns- false.- Returns - trueif this key is equal to- other; otherwise returns- false.- Swaps this ssl key with - other. This operation is very fast and never fails.- toDer([passPhrase=QByteArray()])¶
- Parameters:
- passPhrase – - QByteArray
- Return type:
 
 - Returns the key in DER encoding. - The - passPhraseargument should be omitted as DER cannot be encrypted. It will be removed in a future version of Qt.- toPem([passPhrase=QByteArray()])¶
- Parameters:
- passPhrase – - QByteArray
- Return type:
 
 - Returns the key in PEM encoding. The result is encrypted with - passPhraseif the key is a private key and- passPhraseis non-empty.- Returns the type of the key (i.e., PublicKey or PrivateKey).