zoukankan      html  css  js  c++  java
  • 安装和测试方法

    【赛迪网讯】crypto++加解密算法库,安装和测试方法如下:

    compile Crypto++出crypto.lib档 ;

    使用crypto.lib真正来进行加解密的功能。

    crypto.lib compile过程如下︰

    到Crypto++ 官網下載最新版的Crypto++,我抓的版本是5.5.2 版。到Crypto++官网下载最新版的Crypto++,我抓的版本是5.5.2版。

    开启cryptest.sln档(本档是VS 2005 soluction档,VS 2008需要多做一步soluciton转换的动作)

    开启此soluction后,会发现里面有四个子工程︰cryptdll、cryptest、cryptlib、dlltest,在cryptlib上按滑鼠右键-> Build 。

    等待此project building结束后,在原本Crypto++解压缩的目录下 Win32OutputDebug目录下,会发现有个cryptlib.lib档 ,这样就成功了。

    cryptlib.lib使用过程如下︰

    使用VS 2008建立新工程,工程类型请选择Win32 Console Application 。

    在Application Settings页面中,在" Additional options "中,请勾选" Precompiled header ",再按下Finish按钮结束设定。

    在工程的目录下,建立include目录,把Crypto++ source code中的header file (.h)全部copy到此目录下。

    在工程的目录下,建立lib目录,把上一步骤中所产生的cryptlib.lib档copy到此目录下。

    新增test.cpp档,档案内容我放在后面。

    打开Soluction Explorer window,在我们所建的工程上,按滑鼠右键-> Properties ,设定工程属性。

    C/C++ -> Additional Include Directories设定,加入我们刚刚所建立的include目录路径。

    C/C++ -> Code Generation -> Runtime Library设定,请确定目前模式是/MTd

    Linker -> Additional Libraries Directories设定,加入我们刚刚所建立的lib目录路径。

    Linker -> Command Line设定,加入一行cryptlib.lib 。

    按下F5建build

    <ccid_nobr>
    <ccid_code>测试代码如下:
    
    // 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; 
     }

    如果编译通过说明已经设置成功。

  • 相关阅读:
    eclipse 设置默认编码为Utf-8
    重新打开Eclipse出现“An internal error has occurred. java.lang.NullPointerException”
    Eclipse启动时出现错误 An internal error occurred during: "Updating indexes"
    eclipse卸载自带maven
    JAVA实现SFTP实例
    springboot-24-restTemplate的使用
    Jmeter在restful风格接口测试中的应用
    Swagger介绍-一套流行的API框架
    SQL 里ESCAPE的用法
    CALL 'SYSTEM' ID 'COMMAND'
  • 原文地址:https://www.cnblogs.com/jiaoluo/p/3544358.html
Copyright © 2011-2022 走看看