2012-07-08 142 views
0

我想了解一些关于密码学的知识,并试图在C++中使用加密++库进行AES解密。我有一个密文字符串和一个密钥字符串。使用这两个,我想解密这个密文。这里是我的代码:AES加密+解密入门

#include "mycrypto.h" 
#include <stdio.h> 
#include <cstdlib> 
#include <string> 

#include <aes.h> 
#include <config.h> 
#include <hex.h> 
#include <files.h> 
#include <cryptlib.h> 
#include <modes.h> 
#include <osrng.h> 
#include <filters.h> 
#include <sha.h> 
#include <rijndael.h> 


using namespace std; 
using namespace CryptoPP; 

int main() 
{ 

    string myPlainText; 
    string myKey = "140b41"; 
    string myCipherText = "4ca00f"; 

    byte key[AES::DEFAULT_KEYLENGTH]; 
    byte iv[AES::BLOCKSIZE]; 

    CryptoPP::CBC_Mode<AES>::DECRYPTION decryptor; 
    decryptor.SetKeyWithIV(key, sizeof(key), iv); 

    StringSource(myCipherText, true, new StreamTransformationFilter(decryptor, new StringSink(myPlainText))); 

    return 0; 
} 

我用这段代码得到了许多错误。最直接的是这个:

“解密的”不是的成员“CryptoPP :: CBC_Mode”

任何人都可以理顺我这个代码。我已经完成了crypto ++文档,但我没有看到我做错了什么。

谢谢!

回答

2

我认为DECRYPTION拼写为Decryption。至少,这是如何出现在this example