diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b8bb7d..84ece5d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,4 +108,7 @@ add_executable(PAttribTest utils/PAttribTest.cpp) cm_example_project("utils" PAttribTest) add_executable(Base64Test utils/base64test.cpp) -cm_example_project("utils" Base64Test) \ No newline at end of file +cm_example_project("utils" Base64Test) + +add_executable(HashTest utils/HashTest.cpp) +cm_example_project("utils" HashTest) \ No newline at end of file diff --git a/utils/HashTest.cpp b/utils/HashTest.cpp new file mode 100644 index 0000000..58317ec --- /dev/null +++ b/utils/HashTest.cpp @@ -0,0 +1,69 @@ +#include +#include +#include +#include +#include + +using namespace std; +using namespace hgl; +using namespace hgl::util; + +#if HGL_OS == HGL_OS_Windows +int wmain(int argc,wchar_t **argv) +#else +int main(int argc,char **argv) +#endif//HGL_OS == HGL_OS_Windows +{ + if(argc<2) + { + cout<<"CountHash [filename]"<GetHashBytes(); + + hash_code=new char[hash_length]; + + start_time=GetDoubleTime(); + + h->Init(); + h->Update(file_data,file_length); + h->Final(hash_code); + + end_time=GetDoubleTime(); + + ToLowerHexStr(hash_str,hash_code,hash_length); + + hash_str[hash_length*2]=0; + + h->GetName(hash_name); + + cout<