车辆视频检测器linux版对于密码中包含敏感字符的处理方法

由于密码中含有敏感字符,导致前端页面异常,图标变灰,坐标拾取打不开图像等,主要原因是:密码比较前后不一致,左边是Abc_110+,右边是:Abc_110%2B,对于此问题,特别编写了url编码函数,利用Qt的编码方法对所有敏感字符进行统一处理,然后再进行比较,就OK了,注意opencv的rtsp格式符中不能包含敏感字符,但是SDK登录时,还要使用原始密码,所以密码输入时,要按原始密码输入,使用过程中,需要编码的地方用编码。

cpp 复制代码
//检查是否为重复编码
bool isAlreadyEncoded(const QString &str) {
    // 检查字符串中是否存在 % 后跟两位十六进制数字的模式
    QRegularExpression regex("%[0-9A-Fa-f]{2}");
    return regex.match(str).hasMatch();
}
//检查密码中是否含有敏感字符,如果有则进行url编码,如:@转换为%40,+号转换为%2B等
QString safeEncode(const QString &input) {
    if (isAlreadyEncoded(input)) {
        // 如果已经编码,直接返回原始字符串
        return input;
    } else {
        // 如果未编码,进行编码
        return QString::fromUtf8(input.toUtf8().toPercentEncoding());
    }
}

//检测摄像头参数是否改变
bool DataObj_Camera::checkCamParams(){
    if(id<1 || id>8) return false;
        if(cameraparam.getIp()!=gCarDetectorParams.getCameraIP(id)||
            cameraparam.getUsername()!=gCarDetectorParams.getCameraUsername(id) ||
            safeEncode(cameraparam.getPassword())!=safeEncode(gCarDetectorParams.getCameraPassword(id)) ||
            cameraparam.getPort()!=gCarDetectorParams.getCameraPort(id) ||
            cameraparam.getType()!=gCarDetectorParams.getCameraType(id) ||
            cameraparam.getCodec()!=gCarDetectorParams.getCameraCodec(id) ||
            cameraparam.getInputMode()!=gCarDetectorParams.getCameraInputMode(id)||
            cameraparam.getInputChannel()!=gCarDetectorParams.getCameraInputChannel(id)){
        return false;
    }
    return true;
}
相关推荐
d0ublεU0x002 分钟前
【生存技能】ubuntu 24.04 如何pip install
linux·ubuntu·pip
Javis21116 分钟前
【Linux高级全栈开发】2.1高性能网络-网络编程——2.1.1 网络IO与IO多路复用——select/poll/epoll
linux·运维·网络
刘梓谦21 分钟前
Qt获取CPU使用率及内存占用大小
开发语言·c++·qt
suyukangchen25 分钟前
深入理解 Linux 阻塞IO与Socket数据结构
linux·数据结构·python
yong158585534344 分钟前
[SIGPIPE 错误] 一个 Linux socket 程序,没有任何报错打印直接退出程序
linux·服务器·网络·c++
南隅。2 小时前
【Linux】用户管理
linux
云边有个稻草人3 小时前
【Linux系统】第四节—详解yum+vim
linux·vim·yum·软件包管理器·linux软件生态·linux编辑器-vim使⽤·yum具体操作
dz小伟6 小时前
vim的配置
linux·编辑器·vim
江湖人称-杰8 小时前
CentOS配置了镜像源之后依旧下载元数据失败
linux·运维·centos
阿运河8 小时前
如何配置 VScode 断点调试Linux 工程代码
linux·ide·vscode