crypto7.0移植笔记

本文记录了在Visual Studio 2017环境下移植Crypto7.0库的过程,包括遇到的编译错误如stdio.h等头文件缺失,Windows SDK版本问题,MFC配置等问题,以及解决方法。还涉及到如何添加cryptlib.lib,设置运行库,以及源代码中的RSA加密解密操作。
摘要由CSDN通过智能技术生成

Crypto移植笔记

2018.06.12 许静

 

1.     环境: vs2017, crypto7.0 

2.     修改代码,使编译通过。测试crylib项目。

无法打开源文件stdio.h, stddef.h,stdlib.h等文件, 在包含目录中添加:

C:\Program Files(x86)\Windows Kits\10\Include\10.0.16299.0\ucrt

注意10.0.16299.0版本是否存在本机目录下。

“找不到Windows SDK版本8.1. 请安装所需的版本的Windows SDK或者在项目属性页中或通过右键单击解决方案并选择“重定解决方案目标”来更改SDK版本”。更改一下,不出现错误。

 

3.     添加cryptlib.lib和所有.h文件。

4.     属性->c/c++->代码生成->运行库 多线程调试。

出错。

#error指令:Please use the /MD switch for _AFXDLL builds.

原因:将MFC设置成在共享dll中使用MFC.

解决方案:属性->常规->MFC的使用->在静态库中使用MFC.

 

5.     源文件

  1. #ifndef __RSA_MAIN_H__  
  2. #define __RSA_MAIN_H__  
  3.   
  4. #include <iostream>  
  5. #include <string>  
  6.   
  7.   
  8.   
  9. #define _GEN_RSA        1  
  10. #if !_GEN_RSA  
  11. #define _SPE_RSA    1  
  12. #endif  
  13.   
  14. class RSA_C {  
  15. public:  
  16.     RSA_C(void);  
  17.     ~RSA_C(void);  
  18.     std::string PubEn(const char* message);  
  19.     std::string PriDe(const char* chiphtertext);  
  20.     void GenerateRSAKey(unsigned int keyLength, const char *privFilename, const char *pubFilename, const char *seed);  
  21.   
  22. private:  
  23.     unsigned int keyLen;  
  24.     char *privFilename;  
  25.     char *pubFilename;  
  26.     char *seed;  
  27.     /* 
  28. #if _SPE_RSA 
  29.     RSA::PrivateKey k1; 
  30.     RSA::PublicKey k2; 
  31.     AutoSeededRandomPool rnd; 
  32. #endif 
  33. */  
  34. };  
  35.   
  36. extern RSA_C g_RSA_App;  
  37.   
  38.   
  39.   
  40.   
  41.   
  42.   
  43.   
  44.   
  45. #endif  
 
  1. #include "RSA_main.h"  
  2.   
  3. #include "rsa.h"  
  4. #include "randpool.h"  
  5. #include "hex.h"  
  6. #include "files.h"  
  7. #include "cryptlib.h"  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值