From 649f6f3925fed7692a64ca6d8dc5c8731690e42e Mon Sep 17 00:00:00 2001 From: an-tao Date: Sat, 15 Sep 2018 22:04:52 +0800 Subject: [PATCH] 1.Use OpenSSL as an optional lib;2.Add SHA1 test --- CMakeLists.txt | 2 +- tests/CMakeLists.txt | 5 ++++- tests/Sha1Test.cc | 15 +++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 tests/Sha1Test.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f70a0aa..8e2e67f0 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,7 +47,7 @@ endif() find_package (UUID REQUIRED) include_directories(${UUID_INCLUDE_DIR}) -find_package (OpenSSL REQUIRED) +find_package (OpenSSL) if(OpenSSL_FOUND) #add_definitions(-DUSE_OPENSSL) set(DR_DEFS "USE_OPENSSL;${DR_DEFS}") diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index afafff33..19f22dd1 100755 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,6 +1,9 @@ link_libraries(drogon trantor uuid pthread jsoncpp dl z) - +if(OpenSSL_FOUND) +link_libraries(ssl crypto) +endif() add_executable(cache_map_test CacheMapTest.cc) add_executable(cookies_test CookiesTest.cc) add_executable(class_name_test ClassNameTest.cc) +add_executable(sha1_test Sha1Test.cc) diff --git a/tests/Sha1Test.cc b/tests/Sha1Test.cc new file mode 100644 index 00000000..334cb1cc --- /dev/null +++ b/tests/Sha1Test.cc @@ -0,0 +1,15 @@ +#ifdef USE_OPENSSL +#include +#else +#include "../lib/src/Sha1.h" +#endif +#include +int main() +{ + unsigned char in[]="1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"; + unsigned char out[SHA_DIGEST_LENGTH]={0}; + SHA1(in,100,out); + for(int i=0;i