乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      Vc6.0下搭建 Crypto 環(huán)境

       londonKu 2012-05-05

         首先創(chuàng)建Crypto__test 工程。


              在已編譯好的Cryptopp561中找到Debug文件夾 下的cryptlib.lib 將其改名為cryptlibd.lib后放到上級(jí)目錄中。在Release文件夾下找到cryptlib.lib 將其放到上級(jí)目錄中(不改名)。目的是為以后引用方便。


           在 工具——選項(xiàng) ——目錄中 選擇 Include--files 導(dǎo)入CRYPTOPP561 (方便以后程序中引用) 接著選擇Library files 導(dǎo)入CRYPTOPP561 (這就是問什么剛才需要把兩個(gè)庫(kù)文件放在上級(jí)目錄的原因----方便引用)



        

      在工程———設(shè)置 ——調(diào)試 下  分類中選擇 Code Generation  然后選擇Multithreaded (多線程) 此步非常重要,若不設(shè)置將會(huì)出現(xiàn)2005錯(cuò)誤。


      將如下代碼放入  StdAfx.h 文件中 (主要是編譯時(shí)用到得頭文件和類庫(kù))

      1. #include <iostream>  
      2.   
      3. // Crypto++ Library  
      4. #ifdef _DEBUG  
      5. #  pragma comment( lib, "cryptlibd" )  
      6. #else  
      7. #  pragma comment( lib, "cryptlib" )  
      8. #endif  


       最后在Crypto__test.cpp 中貼入如下源碼:

      1. // Crypto__test.cpp : Defines the entry point for the console application.  
      2. //  
      3.   
      4. #include "stdafx.h"  
      5.   
      6. #include "rsa.h"  
      7. #include "osrng.h"  
      8. #include "integer.h"  
      9. #include "sha.h"  
      10. #include "hex.h"  
      11. #include "filters.h"  
      12.   
      13. int main(int argc, char* argv[])  
      14. {  
      15.     ///////////////////////////////////////  
      16.     // Quote of the Day  
      17.     //   Stephen Hawkins  
      18.     std::string message( "I think computer viruses should count as life. I think it\n" \  
      19.         " says something about human nature that the only form of\n" \  
      20.         " life we have created so far is purely destructive. We've\n" \  
      21.         " created life in our own image." );  
      22.   
      23.     ///////////////////////////////////////  
      24.     // Pseudo Random Number Generator  
      25.     CryptoPP::AutoSeededRandomPool rng;  
      26.   
      27.     ///////////////////////////////////////  
      28.     // Key Generation  
      29.     CryptoPP::InvertibleRSAFunction keys;  
      30.     keys.GenerateRandomWithKeySize( rng, 384 );  
      31.   
      32.     ///////////////////////////////////////  
      33.     // Generated Parameters  
      34.     CryptoPP::Integer n = keys.GetModulus();  
      35.     CryptoPP::Integer p = keys.GetPrime1();  
      36.     CryptoPP::Integer q = keys.GetPrime2();  
      37.     CryptoPP::Integer d = keys.GetPrivateExponent();  
      38.     CryptoPP::Integer e = keys.GetPublicExponent();  
      39.   
      40.     ///////////////////////////////////////  
      41.     // Dump  
      42.     std::cout << "RSA Parameters:" << std::endl;  
      43.     std::cout << " n: " << n << std::endl;  
      44.     std::cout << " p: " << p << std::endl;  
      45.     std::cout << " q: " << q << std::endl;  
      46.     std::cout << " d: " << d << std::endl;  
      47.     std::cout << " e: " << e << std::endl;  
      48.     std::cout << std::endl;  
      49.   
      50.     ///////////////////////////////////////  
      51.     // Signature  
      52.     CryptoPP::RSASS<  
      53.         CryptoPP::PKCS1v15, CryptoPP::SHA  
      54.     >::Signer signer( keys );  
      55.   
      56.     ///////////////////////////////////////  
      57.     // Dump  
      58.     std::cout << "Message:" << std::endl;  
      59.     std::cout << " " << message << std::endl;  
      60.     std::cout << std::endl;  
      61.   
      62.     // Set up for SignMessage()  
      63.     byte* signature = new byte[ signer.MaxSignatureLength() ];  
      64.     if( NULL == signature ) { return -1; }  
      65.   
      66.     // Sign...  
      67.     size_t length = signer.SignMessage( rng, (const byte*) message.c_str(),  
      68.         message.length(), signature );  
      69.   
      70.     ///////////////////////////////////////  
      71.     // Signature Hex Encoding  
      72.     std::string encoded;  
      73.     CryptoPP::HexEncoder encoder( new CryptoPP::StringSink( encoded ),  
      74.         true /* Uppercase */, 2 /* Grouping */":" /* Separator */ );  
      75.     encoder.Put( signature, length );  
      76.     encoder.MessageEnd();  
      77.   
      78.     ///////////////////////////////////////  
      79.     // Dump  
      80.     std::cout << "Signature:" << std::endl;  
      81.     std::cout << " " << encoded << std::endl;  
      82.     std::cout << std::endl;  
      83.   
      84.     ///////////////////////////////////////  
      85.     // Verification  
      86.     CryptoPP::RSASS<  
      87.         CryptoPP::PKCS1v15, CryptoPP::SHA  
      88.     >::Verifier verifier( signer );  
      89.   
      90.     bool result = verifier.VerifyMessage( (const byte*)message.c_str(),  
      91.         message.length(), signature, length );  
      92.   
      93.     ///////////////////////////////////////  
      94.     // Verify Result  
      95.     iftrue == result )  
      96.     {  
      97.         std::cout << "Message Verified" << std::endl;  
      98.     }  
      99.     else  
      100.     {  
      101.         std::cout << "Message Verification Failed" << std::endl;  
      102.     }  
      103.   
      104.     ///////////////////////////////////////  
      105.     // Cleanup  
      106.     if( NULL != signature ) { delete[] signature; }  
      107.   
      108.     return 0;  
      109. }  

      運(yùn)行結(jié)果如下:


      到此有關(guān)crypto++環(huán)境搭建工作基本上已經(jīng)完成。若遇到此文中沒有提及的問題時(shí)可百度查閱相關(guān)資料。

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多