无法在 Devc 上为 SHA-256 哈希编译加密


#include <..cryptoppdll.h>
#include <..cryptoppsha.h>
#include <..cryptopphex.h>
#include<..cryptoppfiles.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/back/..\cryptopp/rijndael.h:7, 来自 C:/Dev-Cpp/include/c++/3.4.2/back/..\cryptopp/aes.h:4, 来自 C:/Dev-Cpp/include/c++/3.4.2/back/..\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: error: function std::string CryptoPP::NameValuePairs::GetValueNames() const' definition is marked dllimport. C:/Dev-Cpp/include/c++/3.4.2/backward/..cryptopp/cryptlib.h:283: error: function bool CryptoPP::NameValuePairs::GetIntValue(const char*, int&( const' definition 被标记为 dllimport。C:/Dev-Cpp/include/c++/3.4.2/backward/..\cryptopp/cryptlib.h:287: error: function 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 static void 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: error: function 'void CryptoPP::NameValuePairs::GetRequiredIntParameter(const char*, const char*, int&( const' definition 标记为 dllimport。

在 C:/Dev-Cpp/include/c++/3.4.2/backward/.. 中包含的文件中。\cryptopp/aes.h:4, 来自 C:/Dev-Cpp/include/c++/3.4.2/back/..\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: error: function '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: error: function 'static const char* CryptoPP::D ES_EDE2_Info::StaticAlgorithmName((' 定义标记为 dllimport。

C:/Dev-Cpp/include/c++/3.4.2/backward/..\cryptopp/des.h:82: error: function 'static const char* CryptoPP::D ES_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:error: function 'static const char* CryptoPP::SKIPJACK_Info::StaticAlgorithmName((' 定义标记为 dllimport。

执行已终止

删除#include <..cryptoppdll.h>

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

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

最新更新