License系统设计(二)

    本文主要讲解License Generator的实现,总体设计请参考前一篇文章。

一、导出导入库

    License Generator是采用QT实现的,它需要导入前面的加解密DLL。导入库的设计如下:

#ifndef AES_DLL_H
#define AES_DLL_H

#ifdef AES_IMPORT
#define AES_API extern "C" __declspec(dllexport)
#else
#define AES_API extern "C" __declspec(dllimport)
#endif

#include <string>
using std::string;

class IEncryptor
{
public:
	virtual void SetKey(unsigned char * key, unsigned char * iv, int length) = 0;

	// encrypt the plainText and generate a file, the plainText should be a string with '\0' end
	virtual bool EncryptString2File(const char * plainText, const char * outFilename) = 0;

	// decyrpt the file and output the recover, you may calculate the size of the file and allocate the space for recover
	virtual bool DecryptFile2String(const char * decFilename, char * recoverText) = 0;
};

AES_API IEncryptor* CreateEncryptor();
AES_API void ReleaseEncryptor(IEncryptor* pEncryptor);

typedef IEncryptor* (*pfnCreateEncryptor)();
typedef void (*pfnReleaseEncryptor)(IEncryptor*);

#endif    // AES_DLL_H

    它主要包括两个导出函数,和一个接口类。这两个导出函数主要复杂管理类对象,主要功能还是在这个接口类中。

这个接口类提供了三个接口:

1)设置加解密的密匙;

2)加密字符串并生成加密文件;

3)将加密文件解密,并输出字符串;

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值