forked from KangLin/RabbitCommon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRabbitCommonEncrypt.h
52 lines (43 loc) · 1.48 KB
/
RabbitCommonEncrypt.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/* Copyright Copyright (c) Kang Lin studio, All Rights Reserved
* Author Kang Lin <[email protected]>
*/
#ifndef CENCRYPT_H_KL_2021_12_10
#define CENCRYPT_H_KL_2021_12_10
#pragma once
#include <string>
#include "rabbitcommon_export.h"
#include <QString>
#include <QByteArray>
namespace RabbitCommon {
/*!
* \brief The encrypt class
* \ingroup API
*/
class RABBITCOMMON_EXPORT CEncrypt
{
public:
CEncrypt(const char* pszPassword = "RabbitCommon");
~CEncrypt();
int SetPassword(const char* pszPassword);
/*!
* \param pIn: 输入要加密的数据指针
* \param inlen: 输入要加密的数据的长度
* \param pOut: 输出加密了的数据指针.调用者使用完成后,需要用delete []*pOut
* \param outLen: 加密了的数据长度
*/
int Encode(const char* pIn, const int &inLen, char** pOut, int &outLen);
int Encode(const QString& szIn, QByteArray& szOut);
/*!
* \param pIn: 输入要解密的数据指针
* \param inlen: 输入要解密的数据的长度
* \param pOut: 输出解密了的数据指针.调用者使用完成后,需要用delete []*pOut
* \param outLen: 解密了的数据长度
*/
int Dencode(const char* pIn, const int &inLen, char** pOut, int &outLen);
int Dencode(const char* pIn, const int &inLen, std::string &szOut);
int Dencode(const QByteArray& szIn, QString& szOut);
private:
std::string m_szPassword;
};
} // namespace RabbitCommon
#endif // CENCRYPT_H_KL_2021_12_10