QMaskGenerator Class

QMaskGenerator 类为自定义 32 位掩码生成器提供了一个抽象基础。更多

头文件: #include <QMaskGenerator>
CMake: find_package(Qt6 REQUIRED COMPONENTS WebSockets)
target_link_libraries(mytarget PRIVATE Qt6::WebSockets)
qmake: QT += websockets
继承: QObject

公共函数

QMaskGenerator(QObject *parent = nullptr)
virtual ~QMaskGenerator() override
virtual quint32 nextMask() = 0
virtual bool seed() = 0

详细说明

RFC 6455中概述的 WebSockets 规范要求对客户端与服务器之间的所有通信进行屏蔽。这是为了防止恶意脚本攻击行为恶劣的代理。有关良好屏蔽重要性的更多信息,请参阅 Lin-Shung Huang 等人撰写的《自说自话,其乐无穷》(Talking to Yourself for Fun and Profit)。默认情况下,QWebSocket 使用相当安全的QRandomGenerator::global()->generate() 函数。防范上述文件中提到的攻击的最佳措施是通过安全连接(wss://)使用QWebSocket 。一般情况下,请务必注意不要让第三方脚本访问应用程序中的QWebSocket

成员函数文档

[explicit] QMaskGenerator::QMaskGenerator(QObject *parent = nullptr)

使用给定的可选QObject parent 创建新的 QMaskGenerator 对象。

[override virtual noexcept] QMaskGenerator::~QMaskGenerator()

销毁QMaskGenerator 对象。

[pure virtual] quint32 QMaskGenerator::nextMask()

返回一个新的 32 位随机掩码。随机性取决于用于创建掩码的 RNG。

[pure virtual] bool QMaskGenerator::seed()

通过为随机化器播种来初始化QMaskGenerator 。如果不调用 seed(),则使用默认种子或根本不使用种子,这取决于子类的具体实现。如果播种成功,则返回true,否则返回 false。

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.