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

时间:2012-07-17 18:50:58

标签: dev-c++ crypto++

#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: function bool CryptoPP :: NameValuePairs :: GetIntValue(const char *,int&amp; ;)const'定义标记为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&amp;,const std :: type_info&amp;)'的定义标记为dllimport。 C:/ Dev-Cpp / include / c ++ / 3.4.2 / backward / .. \ cryptopp / cryptlib.h:301:错误:函数`void CryptoPP :: NameValuePairs :: GetRequiredIntParameter(const char *,const char *,int&amp; ;)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:错误:函数`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

执行终止

1 个答案:

答案 0 :(得分:0)

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

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

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

相关问题