📄 exehashstore.cpp
字号:
#include <string>
#include <vector>
#include <fstream>
using namespace std;
#include "ExeHashStore.h"
#include "Globals.h"
#include "Sha1.h"
#ifdef WRITE_PROGRESS_TO_CONSOLE
#include <iostream>
#endif
string ExeHashStore::getExecutableHash( string exePath )
/*
Description: Copies the first few hundred bytes of the executable described by exePath and returns it as a string
*/
{
string hash;
CSHA1 hasher;
hasher.HashFile( exePath.c_str() );
hasher.Final();
hasher.ReportHash( hash );
return hash;
}
ExeHashStore::ExeHashStore( vector<string> V )
{
FileNames = V;
}
ExeHashStore::ExeHashStore( void )
{
}
void ExeHashStore::setFileNamesVector( vector<string> V )
{
FileNames = V;
}
int ExeHashStore::storeAllHashes( string TargetFileName )
/*
Description: Stores all Hashs in the member vector FileNames to the file described by TargetFileName.
*/
{
ofstream TargetFileHandle( TargetFileName.c_str(), ios_base::trunc );
unsigned int i;
for(i=0;i<FileNames.size() && TargetFileHandle.good();i++)
{
TargetFileHandle
<< i << endl
<< FileNames[i] << endl
<< getExecutableHash( FileNames[i] ) << endl;
#ifdef WRITE_PROGRESS_TO_CONSOLE
cout << FileNames[i] << endl;
#endif
}
TargetFileHandle.close();
return i;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -