随笔 - 7  文章 - 57  trackbacks - 0
<2024年3月>
252627282912
3456789
10111213141516
17181920212223
24252627282930
31123456

常用链接

留言簿(3)

随笔分类

随笔档案

文章分类

文章档案

搜索

  •  

最新评论

阅读排行榜

评论排行榜

背景(只是个人感想,技术上不对后面的内容构成知识性障碍,可以skip):

最近,基于某些原因和需要,笔者需要去了解一下Crypto++库,然后对一些数据进行一些加密解密的操作。

笔者之前没接触过任何加密解密方面的知识(当然,把每个字符的ASCII值加1之流对明文进行加密的“趣事”还是干过的,当时还很乐在其中。),甚至一开始连Crypto++的名字都没有听过,被BS了之后,就开始了Crypto++的入门探索过程。

最初,大概知道了要了解两大类算法中的几个算法——对称加密算法:DES、AES(后来因为人品好的缘故也了解了下非对称加密算法RSA,后文会详述何谓“人品好”);散列算法(需要通过Hash运算):SHA-256。

起初,笔者以为这样的知名算法在网上应该有很多现成的例子。笔者比较懒,对于自己不熟悉的东西,总希望找捷径,直接找别人现(在已经写)成可(编译运)行的代码然后施展ctrl + C,ctrl + V算法(咳,什么算法,是大法!!!)。

However,发觉网上的例子不是稀缺,就是只有代码没有解释。笔者觉得很难忍受这样的“莫名其妙”(奇怪的是笔者容忍了windows了,尽管它不开源),遂决定从零开始……

 

 

 

……写在代码前……


      如果之前像笔者一样没相关经验——完全没接触过加密解密——,请务必阅读下文。
 

一些前期工作——编译cryptlib并使其可用:

      本文不涉及这部分内容,因为已经有相对完善的资料:
        http://www.cnblogs.com/cxun/archive/2008/07/30/743541.html

 

总结了一点预备知识:

关于几个算法的介绍,网上各大百科都有,笔者不再详细Ctrl+C/V了。不过在写代码之前,即使复制修改人家代码之前,也有必要了解一下几个算法(除了名称之外)的使用流程(不是算法具体的实现,汗!)。

 

对称加密:(AES、DES)

相对于与非对称加密而言,加密、解密用的密匙相同就像日常生活中的钥匙,开门和锁门都是同一把。

详见:http://baike.baidu.com/view/119320.htm

 

非对称加密:(RSA)

相对于上述的对称加密而言,加密、解密用的密匙不同有公匙和私匙之分。

详见:http://baike.baidu.com/view/554866.htm 


散列算法:(SHA系列,我们熟悉的MD5等)

用途:验证信息有没有被修改。

原理:对长度大的信息进行提炼(通过一个Hash函数),提炼过后的信息长度小很多,得到的是一个固定长度的值(Hash值)。对于两个信息量很大的文件通过比较这两个值,就知道这两个文件是否完全一致(另外一个文件有没有被修改)。从而避免了把两个文件中的信息进行逐字逐句的比对,减少时间开销。

形象地描述:鬼泣3里面维吉尔跟但丁除了发型之外都很像。怎么区分两个双生子?比较他们的DNA就好比是比较信息量很大的文件,然而直接看发型就好比是看Hash值。一眼就看出来了。

 

注:以上是笔者对几个概念的,非常不严格的,非常主观的,概括的描述,想要详细了解,可以:

http://wenku.baidu.com/view/4fb8e0791711cc7931b716aa.html

几个算法的介绍,选择,比较。

 

 

 

……Code speaking……

 

平台:WindowsXP

IDE以及工具:Visual Studio 2008 + Visual Assist

库版本:Crypto++ 5.6.0

 

 

库的文档(包括类和函数的接口列表):
http://www.cryptopp.com/docs/ref/index.html

 

 

对称加密算法:

DES:

一开始笔者并没有找到关于DES运用的很好的例程,或者说,笔者的搜索功力薄弱,未能找到非常完整的例程吧。

http://bbs.pediy.com/showthread.php?p=745389

笔者以下的代码主要是参考上面URL的论坛回帖,但是作了些修改:

 

 1#include <iostream>
 2#include <des.h>
 3
 4#pragma comment( lib, "cryptlib.lib" )
 5
 6using namespace std;
 7using namespace CryptoPP;
 8
 9int main( void )
10{
11    //主要是打印一些基本信息,方便调试:
12    cout << "DES Parameters: " << endl;
13    cout << "Algorithm name : " << DES::StaticAlgorithmName() << endl; 
14    
15    unsigned char key[ DES::DEFAULT_KEYLENGTH ];
16    unsigned char input[ DES::BLOCKSIZE ] = "12345";
17    unsigned char output[ DES::BLOCKSIZE ];
18    unsigned char txt[ DES::BLOCKSIZE ];
19
20    cout << "input is: " << input << endl;
21
22    //可以理解成首先构造一个加密器
23    DESEncryption encryption_DES;
24
25    //回忆一下之前的背景,对称加密算法需要一个密匙。加密和解密都会用到。
26    //因此,设置密匙。
27    encryption_DES.SetKey( key, DES::KEYLENGTH );
28    //进行加密
29    encryption_DES.ProcessBlock( input, output );
30
31    //显示结果
32    //for和for之后的cout可有可无,主要为了运行的时候看加密结果
33    //把字符串的长度写成一个常量其实并不被推荐。
34    //不过笔者事先知道字符串长,为了方便调试,就直接写下。
35    //这里主要是把output也就是加密后的内容,以十六进制的整数形式输出。
36    forint i = 0; i < 5; i++ )
37    {
38        cout << hex << (int)output[ i ] << ends;
39    }

40    cout << endl;
41
42    //构造一个加密器
43    DESDecryption decryption_DES;    
44
45    //由于对称加密算法的加密和解密都是同一个密匙,
46    //因此解密的时候设置的密匙也是刚才在加密时设置好的key
47    decryption_DES.SetKey( key, DES::KEYLENGTH );
48    //进行解密,把结果写到txt中
49    //decryption_DES.ProcessAndXorBlock( output, xorBlock, txt );
50    decryption_DES.ProcessBlock( output, txt );
51
52    //以上,加密,解密还原过程已经结束了。以下是为了验证:
53    //加密前的明文和解密后的译文是否相等。
54    if ( memcmp( input, txt, 5 ) != 0 )
55    {
56        cerr << "DES Encryption/decryption failed.\n";
57        abort();
58    }

59    cout << "DES Encryption/decryption succeeded.\n";
60    
61    return 0;
62}

63

 回想一下以上代码的编写过程,就可以发现,进行DES加密,流程大概是:
       数据准备;
       构造加密器;
       设置加密密匙;
       加密数据;
       显示(非必要);
       设置解密密匙(跟加密密匙是同一个key);
       解密数据;
       验证与显示(非必要);
       由此可见,主要函数的调用流程就是这样。但是文档没有详细讲,笔者当时打开下载回来的源文件时,就傻了眼。
猜想:
       AES和以后的算法,是不是都是按照这些基本的套路呢?


       AES:   

       在实际运用的时候,从代码上看,AES跟DES非常相像。但是值得注意一点的是,AES取代了DES成为21世纪的加密标准。是因为以其密匙长度和高安全性获得了先天优势。虽然界面上看上去没多大区别,但是破解难度远远大于DES。详细情况,在之前的URL有提及过。
     
       很幸运,笔者很快就找到了AES的使用例程,而且很详细:
      http://dev.firnow.com/course/3_program/c++/cppsl/2008827/138033.html

 1#include <iostream>
 2#include <aes.h>
 3
 4#pragma comment( lib, "cryptlib.lib" )
 5
 6using namespace std; 
 7using namespace CryptoPP;
 8
 9int main()
10{
11
12    //AES中使用的固定参数是以类AES中定义的enum数据类型出现的,而不是成员函数或变量
13    //因此需要用::符号来索引
14    cout << "AES Parameters: " << endl;
15    cout << "Algorithm name : " << AES::StaticAlgorithmName() << endl;      
16
17    //Crypto++库中一般用字节数来表示长度,而不是常用的字节数
18    cout << "Block size     : " << AES::BLOCKSIZE * 8 << endl;
19    cout << "Min key length : " << AES::MIN_KEYLENGTH * 8 << endl;
20    cout << "Max key length : " << AES::MAX_KEYLENGTH * 8 << endl;
21
22    //AES中只包含一些固定的数据,而加密解密的功能由AESEncryption和AESDecryption来完成
23    //加密过程
24    AESEncryption aesEncryptor; //加密器 
25
26    unsigned char aesKey[AES::DEFAULT_KEYLENGTH];  //密钥
27    unsigned char inBlock[AES::BLOCKSIZE] = "123456789";    //要加密的数据块
28    unsigned char outBlock[AES::BLOCKSIZE]; //加密后的密文块
29    unsigned char xorBlock[AES::BLOCKSIZE]; //必须设定为全零
30
31    memset( xorBlock, 0, AES::BLOCKSIZE ); //置零
32
33    aesEncryptor.SetKey( aesKey, AES::DEFAULT_KEYLENGTH );  //设定加密密钥
34    aesEncryptor.ProcessAndXorBlock( inBlock, xorBlock, outBlock );  //加密
35
36    //以16进制显示加密后的数据
37    forint i=0; i<16; i++ ) {
38        cout << hex << (int)outBlock[i] << " ";
39    }

40    cout << endl;
41
42    //解密
43    AESDecryption aesDecryptor;
44    unsigned char plainText[AES::BLOCKSIZE];
45
46    aesDecryptor.SetKey( aesKey, AES::DEFAULT_KEYLENGTH );
47    //细心的朋友注意到这里的函数不是之前在DES中出现过的:ProcessBlock,
48    //而是多了一个Xor。其实,ProcessAndXorBlock也有DES版本。用法跟AES版本差不多。
49    //笔者分别在两份代码中列出这两个函数,有兴趣的朋友可以自己研究一下有何差异。
50    aesDecryptor.ProcessAndXorBlock( outBlock, xorBlock, plainText );
51
52
53    forint i=0; i<16; i++ ) 
54    {      
55        cout << plainText[i];   
56    }

57    cout << endl;
58
59    return 0;
60}

61
62


其实来到这里,都可以发现,加密解密的套路也差不多,至于之后笔者在误打误撞中找到的RSA,也只不过是在设置密匙的时候多了私匙和公匙的区别而已。笔者总觉得,有完整的例程对照学习,是一件很幸福的事情。

 

非对称加密算法:

RSA:

小背景:
       其实,笔者在一开始并没有接到“了解RSA”的要求。不过由于笔者很粗心,在看AES的时候只记得A和S两个字母,Google的时候就误打误撞Google了一个RSA。其实RSA方面的资料还是挺多的,因此它事实上是笔者第一个编译运行成功的Crypto++库中算法的应用实例。
       
         http://www.cnblogs.com/cxun/archive/2008/07/30/743541.html
       以下代码主要是按照上述URL中提供的代码写成的,作为笔者的第一份有效学习资料,笔者认为作为调用者的我们,不用清楚算法实现的细节。只需要明白几个主要函数的功用和调用的次序即可。
       由以下代码可以看出,其实RSA也离不开:数据准备、设置密匙(注意,有公匙和私匙)、加密解密这样的套路。至于如何产生密匙,有兴趣的朋友可以到Crypto++的主页上下载源文件研究。作为入门和了解阶段,笔者觉得:只需要用起来即可。

  1//version at Crypto++ 5.60
  2#include "randpool.h"
  3#include "rsa.h"
  4#include "hex.h"
  5#include "files.h"
  6#include <iostream>
  7
  8using namespace std;
  9using namespace CryptoPP;
 10
 11#pragma comment(lib, "cryptlib.lib")
 12
 13
 14//------------------------
 15
 16// 函数声明
 17
 18//------------------------
 19
 20void GenerateRSAKey( unsigned int keyLength, const char *privFilename, const char *pubFilename, const char *seed  );
 21string RSAEncryptString( const char *pubFilename, const char *seed, const char *message );
 22string RSADecryptString( const char *privFilename, const char *ciphertext );
 23RandomPool & GlobalRNG();
 24
 25//------------------------
 26// 主程序
 27//------------------------
 28
 29void main( void )
 30
 31{
 32    char priKey[ 128 ] = 0 };
 33    char pubKey[ 128 ] = 0 };
 34    char seed[ 1024 ]  = 0 };
 35
 36    // 生成 RSA 密钥对
 37    strcpy( priKey, "pri" );  // 生成的私钥文件
 38    strcpy( pubKey, "pub" );  // 生成的公钥文件
 39    strcpy( seed, "seed" );
 40    GenerateRSAKey( 1024, priKey, pubKey, seed );
 41
 42    // RSA 加解密
 43    char message[ 1024 ] = 0 };
 44    cout<< "Origin Text:\t" << "Hello World!" << endl << endl;
 45    strcpy( message, "Hello World!" );
 46    string encryptedText = RSAEncryptString( pubKey, seed, message );  // RSA 公匙加密
 47    cout<<"Encrypted Text:\t"<< encryptedText << endl << endl;
 48    string decryptedText = RSADecryptString( priKey, encryptedText.c_str() );  // RSA 私匙解密
 49}

 50
 51
 52
 53//------------------------
 54
 55// 生成RSA密钥对
 56
 57//------------------------
 58
 59void GenerateRSAKey(unsigned int keyLength, const char *privFilename, const char *pubFilename, const char *seed)
 60{
 61    RandomPool randPool;
 62    randPool.Put((byte *)seed, strlen(seed));
 63
 64    RSAES_OAEP_SHA_Decryptor priv(randPool, keyLength);
 65    HexEncoder privFile(new FileSink(privFilename));
 66
 67    priv.DEREncode(privFile);
 68    privFile.MessageEnd();
 69
 70    RSAES_OAEP_SHA_Encryptor pub(priv);
 71    HexEncoder pubFile(new FileSink(pubFilename));
 72    pub.DEREncode(pubFile);
 73
 74    pubFile.MessageEnd();
 75
 76    return ;
 77}

 78
 79
 80
 81//------------------------
 82
 83// RSA加密
 84
 85//------------------------
 86
 87string RSAEncryptString( const char *pubFilename, const char *seed, const char *message )
 88{
 89    FileSource pubFile( pubFilename, truenew HexDecoder );
 90    RSAES_OAEP_SHA_Encryptor pub( pubFile );
 91
 92    RandomPool randPool;
 93    randPool.Put( (byte *)seed, strlen(seed) );
 94
 95    string result;
 96    StringSource( message, truenew PK_EncryptorFilter(randPool, pub, new HexEncoder(new StringSink(result))) );
 97    
 98    return result;
 99}

100
101
102
103//------------------------
104// RSA解密
105//------------------------
106
107string RSADecryptString( const char *privFilename, const char *ciphertext )
108{
109    FileSource privFile( privFilename, truenew HexDecoder );
110    RSAES_OAEP_SHA_Decryptor priv(privFile);
111
112    string result;
113    StringSource( ciphertext, truenew HexDecoder(new PK_DecryptorFilter(GlobalRNG(), priv, new StringSink(result))) );
114
115    return result;
116}

117
118
119
120//------------------------
121
122// 定义全局的随机数池
123
124//------------------------
125
126RandomPool & GlobalRNG()
127{
128    static RandomPool randomPool;
129    return randomPool;
130}

131
132


 

散列算法:


SHA-256                                                                                                                                                                                                                                                                     

       SHA-256主要是用来求一大段信息的Hash值,跟之前三个用于加密、解密的算法有所不同。用到SHA的场合,多半是为了校验文件。
       
         笔者的参考资料:http://hi.baidu.com/magic475/blog/item/19b37a8c1fa15a14b21bbaeb.html
       请注意,笔者在实现的时候,稍微修改了一下两个子函数的实现,以满足笔者的需求。因此会与上述URL中的代码有差异。

  1//http://hi.baidu.com/magic475/blog/item/19b37a8c1fa15a14b21bbaeb.html
  2#include <iostream>
  3#include <string.h>
  4
  5#include "sha.h"
  6#include "secblock.h"
  7#include "modes.h"
  8#include "hex.h"
  9
 10#pragma comment( lib, "cryptlib.lib")
 11
 12using namespace std;
 13using namespace CryptoPP;
 14
 15void CalculateDigest(string &Digest, const string &Message);
 16bool VerifyDigest(const string &Digest, const string &Message);
 17
 18int main( void )
 19{
 20    //main函数中注释掉的,关于strMessage2的代码,其实是笔者模拟了一下
 21    //通过求Hash值来对“大”量数据进行校验的这个功能的运用。
 22    //注释之后并不影响这段代码表达的思想和流程。
 23    string strMessage( "Hello world" );
 24    string strDigest;
 25    //string strMessage2( "hello world" ); //只是第一个字母不同
 26    //string strDigest2;
 27
 28    CalculateDigest( strDigest, strMessage );  //计算Hash值并打印一些debug信息
 29    cout << "the size of Digest is: " << strDigest.size() << endl;
 30    cout << "Digest is: " << strDigest << endl;
 31
 32    //CalculateDigest( strDigest2, strMessage2 );
 33    //why put this function here will affect the Verify function?
 34    //作者在写代码的过程中遇到的上述问题。
 35    //如果把这行代码的注释取消,那么之后的运行结果就不是预料中的一样:
 36    //即使strDigest也无法对应strMessage,笔者不知道为什么,希望高手指出,谢谢!
 37
 38    bool bIsSuccess = false;
 39    bIsSuccess = VerifyDigest( strDigest, strMessage ); 
 40    //通过校验,看看strDigest是否对应原来的message
 41    if( bIsSuccess )
 42    {
 43        cout << "sussessive verify" << endl;
 44        cout << "origin string is: " << strMessage << endl << endl;
 45    }

 46    else
 47    {
 48        cout << "fail!" << endl;
 49    }

 50
 51    //通过strDigest2与strMessage进行校验,要是相等,
 52    //就证明strDigest2是对应的strMessage2跟strMessage1相等。
 53    //否则,像这个程序中的例子一样,两个message是不相等的
 54    /*CalculateDigest( strDigest2, strMessage2 );
 55    bIsSuccess = VerifyDigest( strDigest2, strMessage );
 56    if( !bIsSuccess )
 57    {
 58        cout << "success! the tiny modification is discovered~" << endl;
 59        cout << "the origin message is: \n" << strMessage << endl;
 60        cout << "after modify is: \n" << strMessage2 << endl;
 61    }*/

 62    return 0;
 63}

 64
 65
 66//基于某些原因,以下两个子函数的实现跟原来参考代码中的实现有所区别,
 67//详细原因,笔者在CalculateDigest函数的注释中写明
 68void CalculateDigest(string &Digest, const string &Message)
 69{
 70    SHA256 sha256;
 71    int DigestSize = sha256.DigestSize();
 72    char* byDigest;
 73    char* strDigest;
 74
 75    byDigest = new char[ DigestSize ];
 76    strDigest = new char[ DigestSize * 2 + 1 ];
 77
 78    sha256.CalculateDigest((byte*)byDigest, (const byte *)Message.c_str(), Message.size());
 79    memset(strDigest, 0sizeof(strDigest));
 80    //uCharToHex(strDigest, byDigest, DigestSize);
 81    //参考的代码中有以上这么一行,但是貌似不是什么库函数。
 82    //原作者大概是想把Hash值转换成16进制数保存到一个string buffer中,
 83    //然后在主程序中输出,方便debug的时候对照查看。
 84    //但是这并不影响计算Hash值的行为。
 85    //因此笔者注释掉了这行代码,并且修改了一下这个函数和后面的VerifyDigest函数,
 86    //略去原作者这部分的意图,继续我们的程序执行。
 87
 88    Digest = byDigest;
 89
 90    delete []byDigest;
 91    byDigest = NULL;
 92    delete []strDigest;
 93    strDigest = NULL;
 94
 95    return;
 96}

 97
 98bool VerifyDigest(const string &Digest, const string &Message)
 99{
100    bool Result;
101    SHA256 sha256;
102    char* byDigest;
103
104    byDigest = new char[ sha256.DigestSize() ];
105    strcpy( byDigest, Digest.c_str() );
106
107    //HexTouChar(byDigest, Digest.c_str(), Digest.size());
108    //为何注释掉,请参看CalculateDigest函数的注释
109    Result = sha256.VerifyDigest( (byte*)byDigest, (const byte *)Message.c_str(), Message.size() );
110
111    delete []byDigest;
112    byDigest = NULL;
113    return Result;
114}

115
116




        后记:
        为什么写这篇文章呢?因为笔者在搜索过程中觉得这方面的资料有点分散,因此想把它们集中起来,方便刚刚入门的朋友。
         同时,也算是为自己留点学习资料吧。


鸣谢:
jingzhongrong
vczh
没了这两位,在这个宇宙、这个时间、这个维度肯定不会有这篇文章,哈哈!
posted on 2010-12-01 20:19 ArthasLee 阅读(48335) 评论(29)  编辑 收藏 引用 所属分类: 从开源库中学习

FeedBack:
# re: Crypto++入门学习笔记(DES、AES、RSA、SHA-256)[未登录] 2011-04-04 12:41 FanCy
这么好的文章怎么没人评论呢  回复  更多评论
  
# re: Crypto++入门学习笔记(DES、AES、RSA、SHA-256) 2011-04-07 13:37 ArthasLee
当初也花费了一大段时间浏览各种网页,所以有了整理的冲动而已哈。多谢支持~~~@FanCy
  回复  更多评论
  
# 请教您 2011-04-26 10:50 mmxida
您好,读了您的文章,收获很大,谢谢!我有几个不明白的地方,请您指教:1. 您的代码中使用的是公钥加密,私钥解密,我能否倒过来用私钥加密,公钥解密呢?
2. 我查看生成的pri和pub文件,发现pri的长度比pub大很多,这是为什么呢?3. 代码中的seed具体是起什么作用呢,为何加密时需要传入seed,解密又不需要呢?
如您不方便回答,请邮箱联系:mmxida@126.com  回复  更多评论
  
# re: Crypto++入门学习笔记(DES、AES、RSA、SHA-256) 2011-05-09 02:06 fly931
AES::BLOCKSIZE 16
DES::BLOCKSIZ 8
ProcessBlock和ProcessAndXorBlock只能加密一定长度的数据,如果文本的长度超过16,可以这样加密:
std::string PlainText( CW2A((LPCTSTR)m_strSrc));

std::string CipherText;

CryptoPP::CBC_Mode::Encryption
Encryptor( key, sizeof(key), iv );

CryptoPP::StringSource( PlainText, true,
new CryptoPP::StreamTransformationFilter( Encryptor,
new CryptoPP::StringSink( CipherText )
) // StreamTransformationFilter
); // StringSource
CString str;
for( unsigned i=0; i CString strTmp;
strTmp.Format(L"%02X",( static_cast( 0xFF & CipherText[ i ] ) ));
str+=strTmp;
}
SetDlgItemText(IDC_EDIT_AES,str);

谢谢楼主,学到很多东西.问一个问题:你上面的代码是RSA256、512、1024还是2048,我要分别用这四种RSA加密,要怎么实现?会不会是GenerateRSAKey的第一个参数,我试了一下,设成512是错的,其他的都正确  回复  更多评论
  
# re: Crypto++入门学习笔记(DES、AES、RSA、SHA-256) 2011-05-10 00:23 tankle
收获颇丰  回复  更多评论
  
# re: Crypto++入门学习笔记(DES、AES、RSA、SHA-256) 2011-07-10 06:28 perchance
非常感谢楼主 整理的很完整 很有参考价值  回复  更多评论
  
# re: Crypto++入门学习笔记(DES、AES、RSA、SHA-256) 2011-07-22 10:11 ANNMARIEMcbride
Don't have a lot of money to buy a house? You should not worry, just because that's real to take the <a href="http://bestfinance-blog.com/topics/business-loans">business loans</a> to solve such kind of problems. Therefore take a consolidation loan to buy everything you need.   回复  更多评论
  
# re: Crypto++入门学习笔记(DES、AES、RSA、SHA-256) 2011-12-27 22:16 shazhupeng
VerifyDigest有问题吧?
最后byDigest删除了两次,不会出问题么?  回复  更多评论
  
# re: Crypto++入门学习笔记(DES、AES、RSA、SHA-256) 2012-01-12 01:41 buy thesis
A lot of times some people want to order intellectual thesis samples more or less about this good topic from the custom dissertation services. Can you please advice the trustworthy thesis writing service? Thank you so much.   回复  更多评论
  
# re: Crypto++入门学习笔记(DES、AES、RSA、SHA-256) 2012-07-01 17:58 custom research paper help
Here is the company which will fulfill your demands and hand over the order by due date when you decide to buy custom research papers from it.  回复  更多评论
  
# re: Crypto++入门学习笔记(DES、AES、RSA、SHA-256) 2012-07-01 20:23 custom term paper
Don't buy not useful things and pay your cash for buy an essay qualityessay.com service, which would aid you to get a success.   回复  更多评论
  
# re: Crypto++入门学习笔记(DES、AES、RSA、SHA-256) 2012-11-29 14:50 czx1234567
您好!感谢无私的共享,有点不明白的地方向您请教:1、参数“Seed”就是一个任意输入的随机数吗?2、网上看了很多RSA加密原理的介绍,密钥d和公钥e都要配合模数n使用,怎么Crypto++不需要吗。  回复  更多评论
  
# re: Crypto++入门学习笔记(DES、AES、RSA、SHA-256) 2012-12-05 16:03 FlyFish
感谢楼主分享精神,学到不少,又让我遇到不少问题,请问
我在Crypto网站下载的 5.6.1版本的
自己编译出来cryptlib.lib 有 52MB(Release),DebugMode有40多M
请问这是正常的吗?
然后我新建了一个Win32 Console project.然后把人的 AES 那段,放进去,编译
然后报了一堆的错误.

类似
cryptlib.lib(rijndael.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(char const *)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z) already defined in msvcprtd.lib(MSVCP90D.dll)


libcmt.lib(invarg.obj) : error LNK2005: __invoke_watson already defined in MSVCRTD.lib(MSVCR90D.dll)
这问这些错误又是怎么回事。
我用的是vs2008,win7系统  回复  更多评论
  
# re: Crypto++入门学习笔记(DES、AES、RSA、SHA-256) 2012-12-11 10:37 cooldog
很有收获,多谢分享!  回复  更多评论
  
# re: Crypto++入门学习笔记(DES、AES、RSA、SHA-256) 2013-01-22 13:03 Lich
请问有人使用Crypto++6.5.1在vc6.0环境下编译成功的么?  回复  更多评论
  
# re: Crypto++入门学习笔记(DES、AES、RSA、SHA-256)[未登录] 2013-02-15 23:24 阿呆
您的文章对我帮助非常大,
所有Cryptopp的文章就您的最有参考价值,
解说也最清楚,
感谢您的整理与说明。  回复  更多评论
  
# re: Crypto++入门学习笔记(DES、AES、RSA、SHA-256) 2013-04-06 16:35 over here
Professional resume writers review will hint you where to buy resume paper when you are too busy to write a resume, just visit Marvelous Resume company marvelousresume.com, view resume writing samples and our certified resume writers will happily provide you resume writing. Buying resume with us is pretty easy, buy resume now and stay confident about your career.  回复  更多评论
  
# re: Crypto++入门学习笔记(DES、AES、RSA、SHA-256)[未登录] 2013-04-06 16:39 link
If you try to find place where you can get resume services here is very proficient place for you about this topic, which cater examples and gives an pass to learn how make great CV resumes . But this site is more charismatic, and more conducive.  回复  更多评论
  
# re: Crypto++入门学习笔记(DES、AES、RSA、SHA-256) 2013-04-29 15:30 simawei@qq.com
message, true, new PK_EncryptorFilter(randPool, pub, new HexEncoder(new StringSink(result)))

不怕内存泄露么   回复  更多评论
  
# re: Crypto++入门学习笔记(DES、AES、RSA、SHA-256) 2014-03-17 16:37 Hello
@Lich感觉这个库好大啊,我的程序总计都才200多K。谢谢楼主的无私分享,确实学到了不少东西。
  回复  更多评论
  
# re: Crypto++入门学习笔记(DES、AES、RSA、SHA-256) 2014-06-14 10:13 zha_id
谢谢了,受教了  回复  更多评论
  
# re: Crypto++入门学习笔记(DES、AES、RSA、SHA-256) 2014-07-07 10:36 tse
非常好的文章  回复  更多评论
  
# re: Crypto++入门学习笔记(DES、AES、RSA、SHA-256)[未登录] 2014-12-02 14:04 walker
very nice!!!!  回复  更多评论
  
# re: Crypto++入门学习笔记(DES、AES、RSA、SHA-256)[未登录] 2016-04-15 14:14 why
博主有没有试过使用Crypto++动态库进行测试,我见读者都是使用静态库在做测试,我在用动态库测试时编译和运行都遇到了错误,正在解决中。  回复  更多评论
  

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理