Qt通用方法及類庫8

2022-01-29 07:43:42 字數 1512 閱讀 9737

//異或加密演算法

static qstring getxorencryptdecrypt(const qstring &str, char key);

//異或校驗

static uchar getorcode(const qbytearray &data);

//計算校驗碼

static uchar getcheckcode(const qbytearray &data);

//crc校驗

static quint16 getrevcrc_16(quint8 *data, int len, quint16 init, const quint16 *table);

static quint16 getcrc_16(quint8 *data, int len, quint16 init, const quint16 *table);

static quint16 getmodbus16(quint8 *data, int len);

static qbytearray getcrccode(const qbytearray &data);

qstring quihelper::getxorencryptdecrypt(const qstring &str, char key)

return qlatin1string(data);

}uchar quihelper::getorcode(const qbytearray &data)

return result;

}uchar quihelper::getcheckcode(const qbytearray &data)

return temp % 256;

}//函式功能:計算crc16

//引數1:*data 16位crc校驗資料,

//引數2:len 資料流長度

//引數3:init 初始化值

//引數4:table 16位crc查詢表

//逆序crc計算

quint16 quihelper::getrevcrc_16(quint8 *data, int len, quint16 init, const quint16 *table)

return crc_16;

}//正序crc計算

quint16 quihelper::getcrc_16(quint8 *data, int len, quint16 init, const quint16 *table)

return crc_16;

}//modbus crc16校驗

quint16 quihelper::getmodbus16(quint8 *data, int len)

; return getcrc_16(data, len, 0xffff, table_16);

}//crc16校驗

qbytearray quihelper::getcrccode(const qbytearray &data)

Qt通用方法及類庫6

判斷是否是ip位址 static bool isip const qstring ip 判斷是否是mac位址 static bool ismac const qstring mac 判斷是否是合法的 號碼 static bool istel const qstring tel 判斷是否是合法的郵箱位...

Qt通用方法及類庫13

設定按鈕樣式 static qstring setpushbuttonqss qpushbutton btn,按鈕物件 int radius 5,圓角半徑 int padding 8,間距 const qstring normalcolor 34495e 正常顏色 const qstring nor...

Qt通用方法及類庫11

static bool iplive const qstring ip,int port,int timeout 1000 獲取網頁所有源 static qstring gethtml const qstring url 獲取本機公網ip位址 static qstring getnetip cons...