因为paper的原因,需要对加解密算法、数字签名算法和哈希算法进行测试,因此找来crypto++加解密算法库,先介绍一下安装和测试方法:

首先需要compile Crypto++crypto.lib档 ;然后使用crypto.lib真正来进行加解密的功能。
crypto.lib compile过程如下︰
  1. Crypto++ 官網下載最新版的Crypto++,我抓的版本是5.5.2 版。Crypto++官网下载最新版的Crypto++,我抓的版本是5.5.2版。
  2. 开启cryptest.sln档(本档是VS 2005 soluction档,VS 2008需要多做一步soluciton转换的动作)
  3. 开启此soluction后,会发现里面有四个子工程︰cryptdll、cryptest、cryptlib、dlltest,在cryptlib上按滑鼠右键-> Build
  4. 等待此project building结束后,在原本Crypto++解压缩的目录下\ Win32\Output\Debug目录下,会发现有个cryptlib.lib档 ,这样就成功了。
 cryptlib.lib使用过程如下︰
  1. 使用VS 2008建立新工程,工程类型请选择Win32 Console Application
  2. Application Settings页面中,在" Additional options "中,请勾选" Precompiled header ",再按下Finish按钮结束设定。
  3. 在工程的目录下,建立include目录,把Crypto++ source code中的header file (.h)全部copy到此目录下。
  4. 在工程的目录下,建立lib目录,把上一步骤中所产生的cryptlib.lib档copy到此目录下。
  5. 新增test.cpp档,档案内容我放在后面。
  6. 打开Soluction Explorer window,在我们所建的工程上,按滑鼠右键-> Properties ,设定工程属性。
  7. C/C++ -> Additional Include Directories设定,加入我们刚刚所建立的include目录路径。
  8. C/C++ -> Code Generation -> Runtime Library设定,请确定目前模式是/MTd
  9.  Linker -> Additional Libraries Directories设定,加入我们刚刚所建立的lib目录路径。
  10.  Linker -> Command Line设定,加入一行cryptlib.lib
  11. 按下F5建build此工程看看,如果可以build成功就大功告成了!
测试代码如下:

// test1.cpp : Defines the entry point for the console application.

#include "stdafx.h"


#include <dsa.h> 
 using CryptoPP::DSA;
 using CryptoPP::DSA_DER; 
 using CryptoPP::DSA_P1363; 

 #include <pubkey.h> 
 using CryptoPP::PrivateKey;;
 using CryptoPP::PublicKey; 

 #include <osrng.h> 
 using CryptoPP::AutoSeededRandomPool; 

 #include <files.h> 
 using CryptoPP::FileSource; 
 using CryptoPP::FileSink; 
 using CryptoPP::StringSource;
 using CryptoPP::StringSink; 

 int main(int argc, char* argv[])
 {
     AutoSeededRandomPool prng; 
   
     // Crypto++ Key Generation
     DSA::Signer signer;         
     PrivateKey& privateKey = signer.AccessPrivateKey(); 
     privateKey.GenerateRandom( prng ); 

     DSA::Verifier verifier( signer ); 
     PublicKey& publicKey = verifier.AccessPublicKey(); 

     return 0;
 }
如果编译通过说明已经设置成功。