#pragma once
#include  <string>
#include "MsgHead.h"
using namespace std;
class MsgHandle
{
public:
	MsgHandle();
	~MsgHandle();
private:
public:
	//解析报文
	static bool parseHeadMsg(const char* msg,int iLen, MsgHead *head);
	static string parseBodyMsg(const string &msg,const MsgHead &head);
	//写报文
	static void writeHeadMsg(char *pBuf, MsgHead &head);
	static void writeBodyMsg(char *pBuf, string &sBody);
	static void writeMsg(char *pBuf, MsgHead &head, string &sBody);
	static int encodeMsg(char *pBuf, const string &sBody, const MsgHead &head, const string &sSecretKey);
	//解密报文
	static string decryptBody(const MsgHead &msgHead, const char* sBody,int iLen,string secretKey);
	//加密报文
	static string encryptBody(const MsgHead &msgHead, const string& sBody, string secretKey);
	//签名校验
	static bool signVerify(const MsgHead &msgHead,const string& sBody);
	//签名
	static bool sign(MsgHead &msgHead, string& sBody, string& sOut);
};

