1
我正在接收文件及其數值的CRC。我必須重新計算收到的文件上的CRC並進行比較。我正在使用Crypto ++,但它沒有給我數字值。請讓我知道如何使用Crypto ++來計算文件的CRC32。使用Crypto ++將文件的CRC作爲數值計算出來
#include<iostream>
#include<string>
#include <cryptopp/sha.h>
#include <cryptopp/crc.h>
#include <cryptopp/hex.h>
typedef int UInt32;
#include <cryptopp/files.h>
using namespace std;
string calculateCRC(const string& fileName)
{
string result;
CryptoPP::CRC32 hash;
CryptoPP::FileSource(fileName.c_str(),true,
new CryptoPP::HashFilter(hash,
new CryptoPP::StringSink(result)));
return result;
}
int main(int argc, char** argv)
{
cout << endl << calculateCRC("./test.cpp");
}
這給出結果爲「\ 271 \ 063 \ 307Q」。 由於