【发布时间】:2015-06-21 23:12:17
【问题描述】:
我正在使用 Crypto++ 库进行散列。如何散列大于 16kB(字符串大小)的文件?我想要至少像 1Mb 这样的哈希文件。
我得到的错误是文本大于 16kB:
error C2026: string too big, trailing characters truncated
这是我正在使用的代码:
std::string hash;
CryptoPP::SHA512 sha;
CryptoPP::StringSource ss(source, true,
new CryptoPP::HashFilter(sha,
new CryptoPP::HexEncoder(
new CryptoPP::StringSink(hash))));
cout << "SHA-512 hash: " << hash << endl;
【问题讨论】:
-
您在哪里遇到问题?
-
当我想要散列大于 16kB 的文本时:错误 C2026:字符串太大,尾随字符被截断
-
这不是编译器错误,它告诉您不能使用那么长的字符串文字吗?在这种情况下,您可以简单地以另一种方式构建字符串,例如通过从文件中读取。
标签: c++ hash cryptography crypto++