c++ - 创建密文时出现 Crypto++ 错误

标签 c++ build crypto++

我是 C++ 的新手,我需要使用 Crypto++。我一直在寻找解释如何使用它的示例。我找到了这个 Example of AES using Crypto++ .我认为这很棒……唯一的问题是当我尝试构建它时,我遇到了一堆错误!

首先,我必须更改头文件的包含路径。我不知道为什么,但是当我没有在路径前添加“crypto++”时,它找不到头文件。另一篇帖子建议使用它,它似乎可以消除错误。

如果您想查看我正在尝试构建的代码,它在此处:

#include <iostream>
#include <string>
#include <iomanip>

#include "crypto++/modes.h"
#include "crypto++/aes.h"
#include "crypto++/filters.h"
using namespace std;
int main(int argc, char* argv[]) {

    //
    // Key and IV setup
    //AES encryption uses a secret key of a variable length (128-bit, 196-bit or 256-   
    //bit). This key is secretly exchanged between two parties before communication   
    //begins. DEFAULT_KEYLENGTH= 16 bytes
    byte key[ CryptoPP::AES::DEFAULT_KEYLENGTH ], iv[ CryptoPP::AES::BLOCKSIZE ];
    memset( key, 0x00, CryptoPP::AES::DEFAULT_KEYLENGTH );
    memset( iv, 0x00, CryptoPP::AES::BLOCKSIZE );

    //
    // String and Sink setup
    //
    string plaintext = "Now is the time for all good men to come to the aide...";
    string ciphertext;
    string decryptedtext;

    //
    // Dump Plain Text
    //
    cout << "Plain Text (" << plaintext.size() << " bytes)" << endl;
    cout << plaintext;
    cout << endl << endl;

    // //
    // // Create Cipher Text
    // //
    CryptoPP::AES::Encryption aesEncryption(key, CryptoPP::AES::DEFAULT_KEYLENGTH);
    CryptoPP::CBC_Mode_ExternalCipher::Encryption cbcEncryption( aesEncryption, iv );

    CryptoPP::StreamTransformationFilter stfEncryptor(cbcEncryption, new CryptoPP::StringSink( ciphertext ) );
    stfEncryptor.Put( reinterpret_cast<const unsigned char*>( plaintext.c_str() ), plaintext.length() + 1 );
    stfEncryptor.MessageEnd();

    //
    // Dump Cipher Text
    //
    cout << "Cipher Text (" << ciphertext.size() << " bytes)" << endl;

    for( int i = 0; i < ciphertext.size(); i++ ) {

        cout << "0x" << hex << (0xFF & static_cast<byte>(ciphertext[i])) << " ";
    }

    cout << endl << endl;

    //
    // Decrypt
    //
    CryptoPP::AES::Decryption aesDecryption(key, CryptoPP::AES::DEFAULT_KEYLENGTH);
    CryptoPP::CBC_Mode_ExternalCipher::Decryption cbcDecryption( aesDecryption, iv );

    CryptoPP::StreamTransformationFilter stfDecryptor(cbcDecryption, new CryptoPP::StringSink( decryptedtext ) );
    stfDecryptor.Put( reinterpret_cast<const unsigned char*>( ciphertext.c_str() ), ciphertext.size() );
    stfDecryptor.MessageEnd();

    //
    // Dump Decrypted Text
    //
    cout << "Decrypted Text: " << endl;
    cout << decryptedtext;
    cout << endl << endl;

    return 0;
}

这些是我得到的错误

/tmp/cczoSf1S.o: In function `CryptoPP::SimpleKeyingInterface::~SimpleKeyingInterface()':
AES.cpp:(.text._ZN8CryptoPP21SimpleKeyingInterfaceD2Ev[_ZN8CryptoPP21SimpleKeyingInterfaceD5Ev]+0xb): undefined reference to `vtable for CryptoPP::SimpleKeyingInterface'
/tmp/cczoSf1S.o: In function `CryptoPP::SimpleKeyingInterface::SimpleKeyingInterface()':
AES.cpp:(.text._ZN8CryptoPP21SimpleKeyingInterfaceC2Ev[_ZN8CryptoPP21SimpleKeyingInterfaceC5Ev]+0x8): undefined reference to `vtable for CryptoPP::SimpleKeyingInterface'
/tmp/cczoSf1S.o: In function `CryptoPP::BlockTransformation::~BlockTransformation()':
AES.cpp:(.text._ZN8CryptoPP19BlockTransformationD2Ev[_ZN8CryptoPP19BlockTransformationD5Ev]+0xb): undefined reference to `vtable for CryptoPP::BlockTransformation'
/tmp/cczoSf1S.o: In function `CryptoPP::Rijndael::Base::~Base()':
AES.cpp:(.text._ZN8CryptoPP8Rijndael4BaseD2Ev[_ZN8CryptoPP8Rijndael4BaseD5Ev]+0xc): undefined reference to `vtable for CryptoPP::Rijndael::Base'
AES.cpp:(.text._ZN8CryptoPP8Rijndael4BaseD2Ev[_ZN8CryptoPP8Rijndael4BaseD5Ev]+0x16): undefined reference to `vtable for CryptoPP::Rijndael::Base'
/tmp/cczoSf1S.o: In function `CryptoPP::Rijndael::Enc::~Enc()':
AES.cpp:(.text._ZN8CryptoPP8Rijndael3EncD2Ev[_ZN8CryptoPP8Rijndael3EncD5Ev]+0xb): undefined reference to `vtable for CryptoPP::Rijndael::Enc'
AES.cpp:(.text._ZN8CryptoPP8Rijndael3EncD2Ev[_ZN8CryptoPP8Rijndael3EncD5Ev]+0x15): undefined reference to `vtable for CryptoPP::Rijndael::Enc'
/tmp/cczoSf1S.o: In function `CryptoPP::BlockTransformation::BlockTransformation()':
AES.cpp:(.text._ZN8CryptoPP19BlockTransformationC2Ev[_ZN8CryptoPP19BlockTransformationC5Ev]+0x15): undefined reference to `CryptoPP::Algorithm::Algorithm(bool)'
AES.cpp:(.text._ZN8CryptoPP19BlockTransformationC2Ev[_ZN8CryptoPP19BlockTransformationC5Ev]+0x1e): undefined reference to `vtable for CryptoPP::BlockTransformation'
/tmp/cczoSf1S.o: In function `CryptoPP::Rijndael::Base::Base()':
AES.cpp:(.text._ZN8CryptoPP8Rijndael4BaseC2Ev[_ZN8CryptoPP8Rijndael4BaseC5Ev]+0x17): undefined reference to `vtable for CryptoPP::Rijndael::Base'
AES.cpp:(.text._ZN8CryptoPP8Rijndael4BaseC2Ev[_ZN8CryptoPP8Rijndael4BaseC5Ev]+0x21): undefined reference to `vtable for CryptoPP::Rijndael::Base'
/tmp/cczoSf1S.o: In function `CryptoPP::Rijndael::Enc::Enc()':
AES.cpp:(.text._ZN8CryptoPP8Rijndael3EncC2Ev[_ZN8CryptoPP8Rijndael3EncC5Ev]+0x16): undefined reference to `vtable for CryptoPP::Rijndael::Enc'
AES.cpp:(.text._ZN8CryptoPP8Rijndael3EncC2Ev[_ZN8CryptoPP8Rijndael3EncC5Ev]+0x20): undefined reference to `vtable for CryptoPP::Rijndael::Enc'
/tmp/cczoSf1S.o: In function `CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>::BlockCipherFinal(unsigned char const*, unsigned int)':
AES.cpp:(.text._ZN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEC2EPKhj[_ZN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEC5EPKhj]+0x27): undefined reference to `CryptoPP::g_nullNameValuePairs'
AES.cpp:(.text._ZN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEC2EPKhj[_ZN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEC5EPKhj]+0x44): undefined reference to `CryptoPP::SimpleKeyingInterface::SetKey(unsigned char const*, unsigned int, CryptoPP::NameValuePairs const&)'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEE[vtable for CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>]+0x24): undefined reference to `CryptoPP::SimpleKeyingInterface::SetKey(unsigned char const*, unsigned int, CryptoPP::NameValuePairs const&)'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEE[vtable for CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>]+0x3c): undefined reference to `CryptoPP::SimpleKeyingInterface::GetNextIV(CryptoPP::RandomNumberGenerator&, unsigned char*)'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEE[vtable for CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>]+0x44): undefined reference to `CryptoPP::Rijndael::Base::UncheckedSetKey(unsigned char const*, unsigned int, CryptoPP::NameValuePairs const&)'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEE[vtable for CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>]+0x50): undefined reference to `CryptoPP::Rijndael::Enc::ProcessAndXorBlock(unsigned char const*, unsigned char const*, unsigned char*) const'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEE[vtable for CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>]+0x54): undefined reference to `CryptoPP::Rijndael::Enc::AdvancedProcessBlocks(unsigned char const*, unsigned char const*, unsigned char*, unsigned int, unsigned int) const'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEE[vtable for CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>]+0x78): undefined reference to `non-virtual thunk to CryptoPP::Rijndael::Enc::ProcessAndXorBlock(unsigned char const*, unsigned char const*, unsigned char*) const'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEE[vtable for CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>]+0x80): undefined reference to `CryptoPP::BlockTransformation::OptimalDataAlignment() const'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEE[vtable for CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>]+0x90): undefined reference to `non-virtual thunk to CryptoPP::Rijndael::Enc::AdvancedProcessBlocks(unsigned char const*, unsigned char const*, unsigned char*, unsigned int, unsigned int) const'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEES4_EE[vtable for CryptoPP::ClonableImpl<CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>, CryptoPP::Rijndael::Enc>]+0x24): undefined reference to `CryptoPP::SimpleKeyingInterface::SetKey(unsigned char const*, unsigned int, CryptoPP::NameValuePairs const&)'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEES4_EE[vtable for CryptoPP::ClonableImpl<CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>, CryptoPP::Rijndael::Enc>]+0x3c): undefined reference to `CryptoPP::SimpleKeyingInterface::GetNextIV(CryptoPP::RandomNumberGenerator&, unsigned char*)'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEES4_EE[vtable for CryptoPP::ClonableImpl<CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>, CryptoPP::Rijndael::Enc>]+0x44): undefined reference to `CryptoPP::Rijndael::Base::UncheckedSetKey(unsigned char const*, unsigned int, CryptoPP::NameValuePairs const&)'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEES4_EE[vtable for CryptoPP::ClonableImpl<CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>, CryptoPP::Rijndael::Enc>]+0x50): undefined reference to `CryptoPP::Rijndael::Enc::ProcessAndXorBlock(unsigned char const*, unsigned char const*, unsigned char*) const'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEES4_EE[vtable for CryptoPP::ClonableImpl<CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>, CryptoPP::Rijndael::Enc>]+0x54): undefined reference to `CryptoPP::Rijndael::Enc::AdvancedProcessBlocks(unsigned char const*, unsigned char const*, unsigned char*, unsigned int, unsigned int) const'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEES4_EE[vtable for CryptoPP::ClonableImpl<CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>, CryptoPP::Rijndael::Enc>]+0x74): undefined reference to `non-virtual thunk to CryptoPP::Rijndael::Enc::ProcessAndXorBlock(unsigned char const*, unsigned char const*, unsigned char*) const'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEES4_EE[vtable for CryptoPP::ClonableImpl<CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>, CryptoPP::Rijndael::Enc>]+0x7c): undefined reference to `CryptoPP::BlockTransformation::OptimalDataAlignment() const'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEES4_EE[vtable for CryptoPP::ClonableImpl<CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>, CryptoPP::Rijndael::Enc>]+0x8c): undefined reference to `non-virtual thunk to CryptoPP::Rijndael::Enc::AdvancedProcessBlocks(unsigned char const*, unsigned char const*, unsigned char*, unsigned int, unsigned int) const'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP15BlockCipherImplINS_13Rijndael_InfoENS_11BlockCipherEEE[vtable for CryptoPP::BlockCipherImpl<CryptoPP::Rijndael_Info, CryptoPP::BlockCipher>]+0x24): undefined reference to `CryptoPP::SimpleKeyingInterface::SetKey(unsigned char const*, unsigned int, CryptoPP::NameValuePairs const&)'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP15BlockCipherImplINS_13Rijndael_InfoENS_11BlockCipherEEE[vtable for CryptoPP::BlockCipherImpl<CryptoPP::Rijndael_Info, CryptoPP::BlockCipher>]+0x3c): undefined reference to `CryptoPP::SimpleKeyingInterface::GetNextIV(CryptoPP::RandomNumberGenerator&, unsigned char*)'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP15BlockCipherImplINS_13Rijndael_InfoENS_11BlockCipherEEE[vtable for CryptoPP::BlockCipherImpl<CryptoPP::Rijndael_Info, CryptoPP::BlockCipher>]+0x70): undefined reference to `CryptoPP::BlockTransformation::OptimalDataAlignment() const'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP15BlockCipherImplINS_13Rijndael_InfoENS_11BlockCipherEEE[vtable for CryptoPP::BlockCipherImpl<CryptoPP::Rijndael_Info, CryptoPP::BlockCipher>]+0x80): undefined reference to `CryptoPP::BlockTransformation::AdvancedProcessBlocks(unsigned char const*, unsigned char const*, unsigned char*, unsigned int, unsigned int) const'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP13AlgorithmImplINS_25SimpleKeyingInterfaceImplINS_8TwoBasesINS_11BlockCipherENS_13Rijndael_InfoEEES5_EES6_EE[vtable for CryptoPP::AlgorithmImpl<CryptoPP::SimpleKeyingInterfaceImpl<CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info>, CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info> >, CryptoPP::SimpleKeyingInterfaceImpl<CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info>, CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info> > >]+0x24): undefined reference to `CryptoPP::SimpleKeyingInterface::SetKey(unsigned char const*, unsigned int, CryptoPP::NameValuePairs const&)'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP13AlgorithmImplINS_25SimpleKeyingInterfaceImplINS_8TwoBasesINS_11BlockCipherENS_13Rijndael_InfoEEES5_EES6_EE[vtable for CryptoPP::AlgorithmImpl<CryptoPP::SimpleKeyingInterfaceImpl<CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info>, CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info> >, CryptoPP::SimpleKeyingInterfaceImpl<CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info>, CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info> > >]+0x3c): undefined reference to `CryptoPP::SimpleKeyingInterface::GetNextIV(CryptoPP::RandomNumberGenerator&, unsigned char*)'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP13AlgorithmImplINS_25SimpleKeyingInterfaceImplINS_8TwoBasesINS_11BlockCipherENS_13Rijndael_InfoEEES5_EES6_EE[vtable for CryptoPP::AlgorithmImpl<CryptoPP::SimpleKeyingInterfaceImpl<CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info>, CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info> >, CryptoPP::SimpleKeyingInterfaceImpl<CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info>, CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info> > >]+0x6c): undefined reference to `CryptoPP::BlockTransformation::OptimalDataAlignment() const'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP13AlgorithmImplINS_25SimpleKeyingInterfaceImplINS_8TwoBasesINS_11BlockCipherENS_13Rijndael_InfoEEES5_EES6_EE[vtable for CryptoPP::AlgorithmImpl<CryptoPP::SimpleKeyingInterfaceImpl<CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info>, CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info> >, CryptoPP::SimpleKeyingInterfaceImpl<CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info>, CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info> > >]+0x7c): undefined reference to `CryptoPP::BlockTransformation::AdvancedProcessBlocks(unsigned char const*, unsigned char const*, unsigned char*, unsigned int, unsigned int) const'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP25SimpleKeyingInterfaceImplINS_8TwoBasesINS_11BlockCipherENS_13Rijndael_InfoEEES4_EE[vtable for CryptoPP::SimpleKeyingInterfaceImpl<CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info>, CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info> >]+0x24): undefined reference to `CryptoPP::SimpleKeyingInterface::SetKey(unsigned char const*, unsigned int, CryptoPP::NameValuePairs const&)'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP25SimpleKeyingInterfaceImplINS_8TwoBasesINS_11BlockCipherENS_13Rijndael_InfoEEES4_EE[vtable for CryptoPP::SimpleKeyingInterfaceImpl<CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info>, CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info> >]+0x3c): undefined reference to `CryptoPP::SimpleKeyingInterface::GetNextIV(CryptoPP::RandomNumberGenerator&, unsigned char*)'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP25SimpleKeyingInterfaceImplINS_8TwoBasesINS_11BlockCipherENS_13Rijndael_InfoEEES4_EE[vtable for CryptoPP::SimpleKeyingInterfaceImpl<CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info>, CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info> >]+0x68): undefined reference to `CryptoPP::BlockTransformation::OptimalDataAlignment() const'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP25SimpleKeyingInterfaceImplINS_8TwoBasesINS_11BlockCipherENS_13Rijndael_InfoEEES4_EE[vtable for CryptoPP::SimpleKeyingInterfaceImpl<CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info>, CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info> >]+0x78): undefined reference to `CryptoPP::BlockTransformation::AdvancedProcessBlocks(unsigned char const*, unsigned char const*, unsigned char*, unsigned int, unsigned int) const'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP8TwoBasesINS_11BlockCipherENS_13Rijndael_InfoEEE[vtable for CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info>]+0x24): undefined reference to `CryptoPP::SimpleKeyingInterface::SetKey(unsigned char const*, unsigned int, CryptoPP::NameValuePairs const&)'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP8TwoBasesINS_11BlockCipherENS_13Rijndael_InfoEEE[vtable for CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info>]+0x3c): undefined reference to `CryptoPP::SimpleKeyingInterface::GetNextIV(CryptoPP::RandomNumberGenerator&, unsigned char*)'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP8TwoBasesINS_11BlockCipherENS_13Rijndael_InfoEEE[vtable for CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info>]+0x68): undefined reference to `CryptoPP::BlockTransformation::OptimalDataAlignment() const'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP8TwoBasesINS_11BlockCipherENS_13Rijndael_InfoEEE[vtable for CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info>]+0x78): undefined reference to `CryptoPP::BlockTransformation::AdvancedProcessBlocks(unsigned char const*, unsigned char const*, unsigned char*, unsigned int, unsigned int) const'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP11BlockCipherE[vtable for CryptoPP::BlockCipher]+0x24): undefined reference to `CryptoPP::SimpleKeyingInterface::SetKey(unsigned char const*, unsigned int, CryptoPP::NameValuePairs const&)'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP11BlockCipherE[vtable for CryptoPP::BlockCipher]+0x3c): undefined reference to `CryptoPP::SimpleKeyingInterface::GetNextIV(CryptoPP::RandomNumberGenerator&, unsigned char*)'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP11BlockCipherE[vtable for CryptoPP::BlockCipher]+0x68): undefined reference to `CryptoPP::BlockTransformation::OptimalDataAlignment() const'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP11BlockCipherE[vtable for CryptoPP::BlockCipher]+0x78): undefined reference to `CryptoPP::BlockTransformation::AdvancedProcessBlocks(unsigned char const*, unsigned char const*, unsigned char*, unsigned int, unsigned int) const'
/tmp/cczoSf1S.o:(.rodata._ZTIN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEES4_EE[typeinfo for CryptoPP::ClonableImpl<CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>, CryptoPP::Rijndael::Enc>]+0x8): undefined reference to `typeinfo for CryptoPP::Rijndael::Enc'
/tmp/cczoSf1S.o:(.rodata._ZTIN8CryptoPP11BlockCipherE[typeinfo for CryptoPP::BlockCipher]+0x10): undefined reference to `typeinfo for CryptoPP::SimpleKeyingInterface'
/tmp/cczoSf1S.o:(.rodata._ZTIN8CryptoPP11BlockCipherE[typeinfo for CryptoPP::BlockCipher]+0x18): undefined reference to `typeinfo for CryptoPP::BlockTransformation'
/tmp/cczoSf1S.o: In function `CryptoPP::SimpleKeyingInterface::SimpleKeyingInterface(CryptoPP::SimpleKeyingInterface const&)':
AES.cpp:(.text._ZN8CryptoPP21SimpleKeyingInterfaceC2ERKS0_[_ZN8CryptoPP21SimpleKeyingInterfaceC5ERKS0_]+0x8): undefined reference to `vtable for CryptoPP::SimpleKeyingInterface'
/tmp/cczoSf1S.o: In function `CryptoPP::BlockTransformation::BlockTransformation(CryptoPP::BlockTransformation const&)':
AES.cpp:(.text._ZN8CryptoPP19BlockTransformationC2ERKS0_[_ZN8CryptoPP19BlockTransformationC5ERKS0_]+0x1d): undefined reference to `vtable for CryptoPP::BlockTransformation'
/tmp/cczoSf1S.o: In function `CryptoPP::Rijndael::Base::Base(CryptoPP::Rijndael::Base const&)':
AES.cpp:(.text._ZN8CryptoPP8Rijndael4BaseC2ERKS1_[_ZN8CryptoPP8Rijndael4BaseC5ERKS1_]+0x1e): undefined reference to `vtable for CryptoPP::Rijndael::Base'
AES.cpp:(.text._ZN8CryptoPP8Rijndael4BaseC2ERKS1_[_ZN8CryptoPP8Rijndael4BaseC5ERKS1_]+0x28): undefined reference to `vtable for CryptoPP::Rijndael::Base'
/tmp/cczoSf1S.o: In function `CryptoPP::Rijndael::Enc::Enc(CryptoPP::Rijndael::Enc const&)':
AES.cpp:(.text._ZN8CryptoPP8Rijndael3EncC2ERKS1_[_ZN8CryptoPP8Rijndael3EncC5ERKS1_]+0x1d): undefined reference to `vtable for CryptoPP::Rijndael::Enc'
AES.cpp:(.text._ZN8CryptoPP8Rijndael3EncC2ERKS1_[_ZN8CryptoPP8Rijndael3EncC5ERKS1_]+0x27): undefined reference to `vtable for CryptoPP::Rijndael::Enc'
collect2: ld returned 1 exit status
[Finished in 0.7s with exit code 1]
[shell_cmd: g++ "/home/jack/Desktop/Crytpo C++/AES.cpp" -o "/home/jack/Desktop/Crytpo C++/AES"]
[dir: /home/jack/Desktop/Crytpo C++]
[path: /usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games]

我尝试一次输入第 1 行,然后进行构建,但似乎在创建密文时开始出现错误。

最佳答案

你如何编译你的项目?看来您没有链接 crypto++ 库。如果您使用的是 gcc,则可以将 -lcrypto++ 添加到编译选项。

关于c++ - 创建密文时出现 Crypto++ 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22918831/

相关文章:

c++ - 将模板类特化为结构

c++14 - vec.begin() 和 begin(vec) 之间有什么区别

c++ - 不使用 '/' 运算符的除法

c++ - 带有 Crypto++ 库的 QT 控制台应用程序

c++ - HashVerificationFilter 和 "message hash or MAC not valid"异常

c++ - 高效的位操作

build - 如何在 Intellij IDEA 的构建路径中重新包含一个类?

android-maven-插件 : Disable debug build for apk

Android 构建和混淆库项目

android - 如何将 Crypto++ 与 Jni 或 NDK 一起用于 Android 应用程序