0
#include <..\cryptopp\dll.h>
#include <..\cryptopp\sha.h>
#include <..\cryptopp\hex.h>
#include<..\cryptopp\files.h>

#include <iostream>
#include<string>

using namespace std;
using namespace CryptoPP;

const int MAX_PHRASE_LENGTH=250;

int main(int argc, char *argv[]) {

CryptoPP::SHA256 hash;
byte digest[ CryptoPP::SHA256::DIGESTSIZE ];
std::string message = "Hello World!";

hash.CalculateDigest( digest, (const byte*)message.c_str(), message.length());

CryptoPP::HexEncoder encoder;
std::string output;
encoder.Attach( new CryptoPP::StringSink( output ) );
encoder.Put( digest, sizeof(digest) );
encoder.MessageEnd();

std::cout << "Input string: " << message << std::endl;
std::cout << "SHA256: " << output << std::endl;

return 0;
}

错误

编译器:默认编译器正在执行 g++.exe... g++.exe "C:\Users\Pr\Desktop\Work\encrypt\sha256\sampeSHA256.cpp" -o "C:\Users\Pr\Desktop\Work\encrypt\ sha256\sampeSHA256.exe" -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\Dev-Cpp\include\c++\3.4.2\backward" -I "C:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\Dev-Cpp\include\c++\3.4.2" -I"C:\Dev-Cpp\include" -L "C:\Dev-Cpp\lib" 在来自 C:/Dev-Cpp/include/c++/3.4.2/backward/..\cryptopp/seckey.h:8 的文件中,来自 C:/Dev-Cpp/ include/c++/3.4.2/backward/..\cryptopp/rijndael.h:7,来自 C:/Dev-Cpp/include/c++/3.4.2/backward/..\cryptopp/aes.h:4,来自 C:/Dev-Cpp/include/c++/3.4.2/backward/..\cryptopp\dll.h:11,来自 C:\Users\Pr\Desktop\Work\encrypt\sha256\sampeSHA256.cpp:1: C:/Dev-Cpp/include/c++/3.4.2/backward/..\cryptopp/cryptlib.h:277: 错误:函数std::string CryptoPP::NameValuePairs::GetValueNames() const' definition is marked dllimport. C:/Dev-Cpp/include/c++/3.4.2/backward/..\cryptopp\/cryptlib.h:283: error: functionbool CryptoPP::NameValuePairs::GetIntValue(const char*, int&) const' 定义标记为 dllimport。C:/Dev-Cpp/include/c++/3.4.2/backward/..\cryptopp/cryptlib.h:287: 错误:函数int CryptoPP::NameValuePairs::GetIntValueWithDefault(const char*, int) const' definition is marked dllimport. C:/Dev-Cpp/include/c++/3.4.2/backward/..\cryptopp\/cryptlib.h:291: error: function静态无效 CryptoPP::NameValuePairs::ThrowIfTypeMismatch(const char*, const std::type_info& , const std::type_info&)' 定义被标记为 dllimport。C:/Dev-Cpp/include/c++/3.4.2/backward/..\cryptopp/cryptlib.h:301: 错误: 函数`void CryptoPP::NameValuePairs::GetRequiredIntParameter(const char*, const char*, int& ) const' 定义被标记为 dllimport。

在来自 C:/Dev-Cpp/include/c++/3.4.2/backward/..\cryptopp/aes.h:4 的文件中,来自 C:/Dev-Cpp/include/c++/3.4.2/backward/ ..\cryptopp\dll.h:11,来自 C:\Users\Pr\Desktop\Work\encrypt\sha256\sampeSHA256.cpp:1: C:/Dev-Cpp/include/c++/3.4.2/backward/ ..\cryptopp/rijndael.h:15:错误:函数 `static const char* CryptoPP::Rijndael_Info::StaticAlgorithmName()' 定义标记为 dllimport。

在来自 C:/Dev-Cpp/include/c++/3.4.2/backward/..\cryptopp\dll.h:16 的文件中,来自 C:\Users\Pr\Desktop\Work\encrypt\sha256\sampeSHA256。 cpp:1: C:/Dev-Cpp/include/c++/3.4.2/backward/..\cryptopp/des.h:58: 错误:函数`static const char* CryptoPP::DES_EDE2_Info::StaticAlgorithmName()'定义标记为 dllimport。

C:/Dev-Cpp/include/c++/3.4.2/backward/..\cryptopp/des.h:82: error: function `static const char* CryptoPP::DES_EDE3_Info::StaticAlgorithmName()' 定义标记为 dllimport .

在来自 C:/Dev-Cpp/include/c++/3.4.2/backward/..\cryptopp\dll.h:37 的文件中,来自 C:\Users\Pr\Desktop\Work\encrypt\sha256\sampeSHA256。 cpp:1: C:/Dev-Cpp/include/c++/3.4.2/backward/..\cryptopp/skipjack.h:15: 错误:函数`static const char* CryptoPP::SKIPJACK_Info::StaticAlgorithmName()'定义标记为 dllimport。

执行终止

4

1 回答 1

0

消除#include <..\cryptopp\dll.h>

正如弗雷泽所说,使用-L<path to Crypto++>.

正如弗雷泽所说,使用-lcryptoppor -lcrypto++。您使用的取决于您所拥有的。默认情况下,它的-lcryptopp.

于 2014-01-28T03:54:08.817 回答