一、描述
QSslCipher 类表示 SSL 加密密码。
QSslCipher 存储有关一种加密密码的信息。它最常与 QSslSocket 一起使用,用于表示socket可以使用的密码。
二、使用示例
QSslSocket *socket = new QSslSocket;
socket->connectToHostEncrypted("www.baidu.com", 443);
QSslSocket::connect(socket, static_cast<void(QSslSocket::*)(QAbstractSocket::SocketState)>(&QSslSocket::stateChanged),[](QAbstractSocket::SocketState state)
{
qDebug() << "socket状态:" << state;
});
QSslSocket::connect(socket, &QSslSocket::encrypted, [socket]()
{
QSslCipher ciph = socket->sessionCipher();
qDebug()<<"密码名称:"<< ciph.name();
qDebug()<<"协议(名称):"<< ciph.protocolString();
qDebug()<<"协议("<<ciph.protocolString()<<"的枚举值):"<< ciph.protocol();
qDebug()<<"密码使用的位数:"<< ciph.usedBits();
qDebug()<<"密码支持的位数:"<< ciph.supportedBits();
qDebug()<<"密码的加密方法:"<< ciph.encryptionMethod();
qDebug()<<"密码的密钥交换方法:"<< ciph.keyExchangeMethod();
qDebug()<<"密码的身份验证方法:"<< ciph.authenticationMethod();
});
关于为什么连接433端口:433端口