Commit 17a406cb by 刘帅

修改为在每次请求消息中添加sign,添加LICENSE

parent 12ec6bcb
Freemud Public License 1.0
/* ====================================================================
* Copyright (c) 2015-2019 Freemud Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice.
*
* 2. All distribution of Covered Software in Source Code Form, including any
* Modifications that You create or to which You contribute, must be
* authorised by Freemud.
*
* 3. When distribution of Source Form, You must inform recipients that the
* Source Code Form of the Covered Software is governed by the terms of this
* License, and how they can obtain a copy of this License. You may not
* attempt to alter or restrict the recipients' rights in the Source Code
* Form.
*
* 4. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 5. All advertising materials mentioning features or use of this
* software must display the following acknowledgment:
* "This product includes software developed by the Freemud Group
* for use in McDonald's POS in China mainland, Hongkong."
*
* ====================================================================
*
* For more information about Freemud, please see <http://www.freemud.cn/>.
*
*/
// FPe.h
//
// Copyright (c) 2015-2019 Freemud Co., Ltd.
//
// process PE header.
#include <string>
#include "Windows.h"
using namespace std;
......
......@@ -27,7 +27,7 @@ namespace FmMd5{
return tempstr.c_str();
}
std::string FileDigest(std::string file,int minusCount) {
std::string FileDigest(std::string file,int minusCount,int ix) {
ifstream in(file.c_str(), ios::binary);
if (!in) {
return "";
......@@ -36,9 +36,17 @@ namespace FmMd5{
in.seekg(0, ios_base::end);
int nFileLen = in.tellg();
in.seekg(0,ios_base::beg);
double iCount=ceil((double)nFileLen/1024);
double iCount;
if (ix == 1)
{
iCount=ceil((double)nFileLen/1024);
}else{
int cc=nFileLen -74;
iCount=ceil((double)cc/1024);
}
iCount=iCount-minusCount;
if (iCount <=0)
if (iCount <= 0)
{
return "";
}
......@@ -56,7 +64,7 @@ namespace FmMd5{
md5.update(buffer, length);
}
if (i == iCount)
if (i >= iCount)
{
//md5.update(buffer, length);
break;
......
// FmPee.h
//
// Copyright (c) 2015-2019 Freemud Co., Ltd.
//
// Md5 code generated by class FmMd5 .
#include <string>
using namespace std;
......@@ -5,8 +11,8 @@ using namespace std;
namespace FmMd5{
std::string FileDigest(std::string file);
std::string FileDigest(std::string file,int minusCount);
std::string FileDigest(std::string file,int minusCount,int i); // false
}
namespace FmPeeEncrypt{
std::string FmEncryptKey(std::string sourcestr, std::string time);
}
\ No newline at end of file
}
......@@ -42,17 +42,17 @@ int main(int argc, char *argv[])
qDebug() << "verify failed! this application can not run.";
return 0;
}
QFmClient client;
if(!client.verifyWhitelists())
{
OutputDebugStringA("verify whitelists failed");
return 0;
}
// QFmClient client;
// if(!client.verifyWhitelists())
// {
// OutputDebugStringA("verify whitelists failed");
// return 0;
// }
InitLogger();
QLOG_INFO()<<"start FmclientUi...";
Widget w;
scanner s;
//QFmClient client;
QFmClient client;
QObject::connect(&client,&QFmClient::HideUi, &w, &Widget::hide,Qt::QueuedConnection);
QObject::connect(&client,&QFmClient::ShowUi, &w, &Widget::showRequesting,Qt::QueuedConnection);
QObject::connect(&client, &QFmClient::ShowRefundUi, &s, &scanner::showRefund);
......
......@@ -55,6 +55,10 @@ QFmClient::QFmClient(QObject *parent) : QThread(parent)
bool QFmClient::Init(QString proxy_IP, unsigned short proxy_port, unsigned short listen_prot, unsigned short long_timeout, unsigned short short_timeout)
{
QString filePath = QCoreApplication::applicationFilePath();
std::string sign = FmMd5::FileDigest(filePath.toStdString().c_str(),2, 2).c_str();
m_sign = QString(sign.c_str());
QString fileName = qApp->applicationDirPath();
fileName.append(QDir::separator());
fileName.append(CONFIGURE_FILE_NAME);
......@@ -426,6 +430,7 @@ int QFmClient::ProcessPosReqData(QJsonObject& object)
object["trans_id"] = trans_id;
}
qDebug()<<object;
object.insert("sign", m_sign); //add sign item to every message
do
{
......@@ -1007,7 +1012,7 @@ bool QFmClient::verifyWhitelists()
return false;
}
QString filePath = QCoreApplication::applicationFilePath();
std::string sign = FmMd5::FileDigest(filePath.toStdString().c_str(),2).c_str();
std::string sign = FmMd5::FileDigest(filePath.toStdString().c_str(),2,2).c_str();
OutputDebugStringA(sign.c_str());
QJsonObject verifyObject;
......@@ -1318,6 +1323,7 @@ void QFmClient::CheckRollBackData()
}
QJsonObject json = doc.object();
json.insert("sign", m_sign); //add sign item to every message
json["reqtype"] = 3;
AddReqCount(json);
......
......@@ -119,6 +119,7 @@ public:
QString _refundTransId;
static unsigned int s_reqCount;
QString m_sign;
};
#endif // QFMCLIENT_H
......@@ -8,7 +8,7 @@ bool VerifySign(std::string filepath,std::string encryptstr)
if (encryptstr.find("|") != -1)
{
//计算局部md5
std:string md5str=FmMd5::FileDigest(filepath.c_str(),2).c_str();
std:string md5str=FmMd5::FileDigest(filepath.c_str(),2, 2).c_str();
std::string g_filemd5="";//局部md5
std::string g_date=""; //日期
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment