1.Use OpenSSL as an optional lib;2.Add SHA1 test

This commit is contained in:
an-tao 2018-09-15 22:04:52 +08:00
parent 1f5ab069f9
commit 649f6f3925
3 changed files with 20 additions and 2 deletions

View File

@ -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}")

View File

@ -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)

15
tests/Sha1Test.cc Normal file
View File

@ -0,0 +1,15 @@
#ifdef USE_OPENSSL
#include <openssl/sha.h>
#else
#include "../lib/src/Sha1.h"
#endif
#include <stdio.h>
int main()
{
unsigned char in[]="1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890";
unsigned char out[SHA_DIGEST_LENGTH]={0};
SHA1(in,100,out);
for(int i=0;i<SHA_DIGEST_LENGTH;i++)
printf("%02x",out[i]);
putchar('\n');
}