Added ostd::Utils::md5 function
This commit is contained in:
parent
9b7873eda1
commit
af2eff4ce3
5 changed files with 46 additions and 10 deletions
17
.vscode/settings.json
vendored
17
.vscode/settings.json
vendored
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"C_Cpp.errorSquiggles": "enabled",
|
||||
"files.associations": {
|
||||
"*.dss": "python",
|
||||
"functional": "cpp",
|
||||
"thread": "cpp",
|
||||
"cctype": "cpp",
|
||||
|
|
@ -96,7 +97,12 @@
|
|||
"stacktrace": "cpp",
|
||||
"*.ipp": "cpp",
|
||||
"format": "cpp",
|
||||
"stdfloat": "cpp"
|
||||
"stdfloat": "cpp",
|
||||
"*.inc": "cpp",
|
||||
"text_encoding": "cpp"
|
||||
},
|
||||
"workbench.editorAssociations": {
|
||||
"*.bin": "hexEditor.hexedit"
|
||||
},
|
||||
|
||||
"workbench.colorCustomizations": {
|
||||
|
|
@ -157,5 +163,12 @@
|
|||
"cmake.configureOnOpen": false,
|
||||
"cmake.options.statusBarVisibility": "hidden",
|
||||
|
||||
"git.openRepositoryInParentFolders": "never"
|
||||
"git.openRepositoryInParentFolders": "never",
|
||||
|
||||
"python.languageServer": "None",
|
||||
|
||||
"files.eol": "\r\n",
|
||||
|
||||
"workbench.iconTheme": "material-icon-theme",
|
||||
"workbench.colorTheme": "Aramok's GLX Black"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,8 +87,9 @@ if (UNIX)
|
|||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath='$ORIGIN'")
|
||||
target_link_libraries(${OMNIA_STD_LIB} PUBLIC tinfo boost_regex)
|
||||
target_link_libraries(${OMNIA_GFX_LIB} PUBLIC xcb xcb-randr)
|
||||
endif (UNIX)
|
||||
endif (UNIX)
|
||||
target_link_libraries(${OMNIA_GFX_LIB} PUBLIC SDL2main SDL2 SDL2_gfx SDL2_ttf)
|
||||
target_link_libraries(${OMNIA_STD_LIB} PUBLIC ssl crypto)
|
||||
#-----------------------------------------------------------------------------------------
|
||||
|
||||
#Finalize
|
||||
|
|
|
|||
2
build.nr
2
build.nr
|
|
@ -1 +1 @@
|
|||
1867
|
||||
1872
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
#include <iostream>
|
||||
#include <thread>
|
||||
#include <cmath>
|
||||
#include <openssl/evp.h>
|
||||
|
||||
#define __get_local_time() \
|
||||
std::time_t __cur_t = std::time(0); \
|
||||
|
|
@ -423,7 +424,7 @@ namespace ostd
|
|||
case 6: return "Sa";
|
||||
default: return "Unknown day";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -436,7 +437,7 @@ namespace ostd
|
|||
{
|
||||
if (__destination == nullptr)
|
||||
{
|
||||
std::cout << "\n\n" << termcolor::magenta << "====> ";
|
||||
std::cout << "\n" << termcolor::magenta << "====> ";
|
||||
std::cout << termcolor::cyan << "Starting test for [";
|
||||
std::cout << termcolor::green << m_name;
|
||||
std::cout << termcolor::cyan << "]";
|
||||
|
|
@ -446,11 +447,11 @@ namespace ostd
|
|||
else
|
||||
{
|
||||
m_dest = __destination;
|
||||
m_dest->nl().nl().fg("magenta").p("====> ");
|
||||
m_dest->nl().fg("magenta").p("====> ");
|
||||
m_dest->fg("cyan").p("Starting test for [");
|
||||
m_dest->fg("green").p(m_name);
|
||||
m_dest->fg("cyan").p("]");
|
||||
m_dest->nl().nl().fg("magenta").p(" <====");
|
||||
m_dest->fg("magenta").p(" <====");
|
||||
m_dest->reset().nl();
|
||||
}
|
||||
}
|
||||
|
|
@ -530,7 +531,7 @@ namespace ostd
|
|||
{
|
||||
if (m_dest == nullptr)
|
||||
{
|
||||
std::cout << "\n" << termcolor::magenta << "====> ";
|
||||
std::cout << termcolor::magenta << "====> ";
|
||||
std::cout << termcolor::cyan << "Test for [";
|
||||
std::cout << termcolor::green << m_name;
|
||||
std::cout << termcolor::cyan << "] took ";
|
||||
|
|
@ -540,7 +541,7 @@ namespace ostd
|
|||
}
|
||||
else
|
||||
{
|
||||
m_dest->nl().fg("magenta").p("====> ");
|
||||
m_dest->fg("magenta").p("====> ");
|
||||
m_dest->fg("cyan").p("Test for [");
|
||||
m_dest->fg("green").p(m_name);
|
||||
m_dest->fg("cyan").p("] took ");
|
||||
|
|
@ -829,4 +830,24 @@ namespace ostd
|
|||
}
|
||||
return out_string;
|
||||
}
|
||||
|
||||
String Utils::md5(const String& str)
|
||||
{
|
||||
using namespace std;
|
||||
EVP_MD_CTX* context = EVP_MD_CTX_new();
|
||||
const EVP_MD* md = EVP_md5();
|
||||
unsigned char md_value[EVP_MAX_MD_SIZE];
|
||||
unsigned int md_len;
|
||||
string output;
|
||||
|
||||
EVP_DigestInit_ex2(context, md, NULL);
|
||||
EVP_DigestUpdate(context, str.c_str(), str.len());
|
||||
EVP_DigestFinal_ex(context, md_value, &md_len);
|
||||
EVP_MD_CTX_free(context);
|
||||
|
||||
output.resize(md_len * 2);
|
||||
for (unsigned int i = 0 ; i < md_len ; ++i)
|
||||
std::sprintf(&output[i * 2], "%02x", md_value[i]);
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -182,6 +182,7 @@ namespace ostd
|
|||
static bool loadByteStreamFromFile(const String& filePath, ByteStream& outStream);
|
||||
static ByteStream stringToByteStream(const String& data);
|
||||
static String byteStreamToString(const ByteStream& data);
|
||||
static String md5(const String& str);
|
||||
|
||||
//Implemented in <FileSystem.cpp>
|
||||
static std::vector<std::filesystem::path> listFilesInDirectory(const String& directoryPath);
|
||||
|
|
|
|||
Loading…
Reference in a new issue