In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the knowledge of "how to implement the Qt key generator". Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
I. Preface
In many commercial software, we need to provide some trial versions, so we need to support the key mechanism to control, throughout most of the trial software, basically use the following mechanisms to control.
Remote networking is activated, and every startup is connected to the network to check the usage time, etc., this method is the most perfect, but the disadvantage is that the devices that can not be connected to the Internet will stop.
By getting the number of the local hard disk + CPU and other hardware, do a calculation to generate an activation code, more than half of the software will use this method, the disadvantage is that you can not freely control other parameters of the software, such as the number of devices added to the software.
Set a key file of running expiration time + quantity limit + running time, and send it to the user to use the supporting software. the disadvantage is that if only the running expiration time is set, the user can change the computer time to get a longer use time. when the computer is not connected to the Internet. This demo adopts the form of throwing a brick to attract jade, and uses the third method to realize. The key file uses the simplest XOR encryption, which can be changed to other encryption methods.
2. Code idea QString frmMain::getWMIC (const QString & cmd) {/ / get cpu name: wmic cpu get Name / / get cpu Core number: wmic cpu get NumberOfCores / / get CPU Thread number: wmic cpu get NumberOfLogicalProcessors / / query cpu Serial number: wmic cpu get processorid / / query Motherboard Serial number: wmic baseboard get serialnumber / / query BIOS Serial number: wmic bios get serialnumber / / View hard disk: wmic diskdrive get serialnumber QProcess p P.start (cmd); p.waitForFinished (); QString result = QString::fromLocal8Bit (p.readAllStandardOutput ()); QStringList list = cmd.split (""); result = result.remove (list.last (), Qt::CaseInsensitive); result = result.replace ("\ r", "); result = result.replace ("\ n ","); result = result.simplified (); return result } QString frmMain::getCpuName () {return getWMIC ("wmic cpu get name");} QString frmMain::getCpuId () {return getWMIC ("wmic cpu get processorid");} QString frmMain::getDiskNum () {return getWMIC ("wmic diskdrive where index=0 get serialnumber");} QString frmMain::getXorEncryptDecrypt (const QString & data, char key) {/ / XOR encryption, or you can change the algorithm QByteArray buffer = data.toLatin1 (); int size = buffer.size () For (int I = 0; I
< size; i++) { buffer[i] = buffer.at(i) ^ key; } return QLatin1String(buffer);}void frmMain::on_btnOk_clicked(){ bool useDate = ui->CkDate- > isChecked (); bool useRun = ui- > ckRun- > isChecked (); bool useCount = ui- > ckCount- > isChecked (); if (! useDate & &! useRun & &! useCount) {if (QMessageBox::question (this, "ask", "are you sure you want to generate an unlimited key?")! = QMessageBox::Yes) {return }} QString strDate = ui- > dateEdit- > date (). ToString ("yyyy-MM-dd"); QString strRun = ui- > cboxMin- > currentText (); QString strCount = ui- > cboxCount- > currentText (); QString key = QString ("% 1 |% 2 |% 3 |% 5 |% 6") .arg (useDate) .arg (strDate) .arg (useRun) .arg (strRun) .arg (useCount) .arg (strCount); QFile file (QApplication::applicationDirPath () + "/ key.db") File.open (QFile::WriteOnly | QIODevice::Text); file.write (getXorEncryptDecrypt (key, 110th). ToLatin1 (); file.close (); QMessageBox::information (this, "prompt", "key generated successfully, copy the key.db file to the corresponding directory!");} 3.
This is the end of "how to implement the Qt key generator". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.