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",
|
"C_Cpp.errorSquiggles": "enabled",
|
||||||
"files.associations": {
|
"files.associations": {
|
||||||
|
"*.dss": "python",
|
||||||
"functional": "cpp",
|
"functional": "cpp",
|
||||||
"thread": "cpp",
|
"thread": "cpp",
|
||||||
"cctype": "cpp",
|
"cctype": "cpp",
|
||||||
|
|
@ -96,7 +97,12 @@
|
||||||
"stacktrace": "cpp",
|
"stacktrace": "cpp",
|
||||||
"*.ipp": "cpp",
|
"*.ipp": "cpp",
|
||||||
"format": "cpp",
|
"format": "cpp",
|
||||||
"stdfloat": "cpp"
|
"stdfloat": "cpp",
|
||||||
|
"*.inc": "cpp",
|
||||||
|
"text_encoding": "cpp"
|
||||||
|
},
|
||||||
|
"workbench.editorAssociations": {
|
||||||
|
"*.bin": "hexEditor.hexedit"
|
||||||
},
|
},
|
||||||
|
|
||||||
"workbench.colorCustomizations": {
|
"workbench.colorCustomizations": {
|
||||||
|
|
@ -157,5 +163,12 @@
|
||||||
"cmake.configureOnOpen": false,
|
"cmake.configureOnOpen": false,
|
||||||
"cmake.options.statusBarVisibility": "hidden",
|
"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"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,7 @@ if (UNIX)
|
||||||
target_link_libraries(${OMNIA_GFX_LIB} PUBLIC xcb xcb-randr)
|
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_GFX_LIB} PUBLIC SDL2main SDL2 SDL2_gfx SDL2_ttf)
|
||||||
|
target_link_libraries(${OMNIA_STD_LIB} PUBLIC ssl crypto)
|
||||||
#-----------------------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#Finalize
|
#Finalize
|
||||||
|
|
|
||||||
2
build.nr
2
build.nr
|
|
@ -1 +1 @@
|
||||||
1867
|
1872
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <openssl/evp.h>
|
||||||
|
|
||||||
#define __get_local_time() \
|
#define __get_local_time() \
|
||||||
std::time_t __cur_t = std::time(0); \
|
std::time_t __cur_t = std::time(0); \
|
||||||
|
|
@ -436,7 +437,7 @@ namespace ostd
|
||||||
{
|
{
|
||||||
if (__destination == nullptr)
|
if (__destination == nullptr)
|
||||||
{
|
{
|
||||||
std::cout << "\n\n" << termcolor::magenta << "====> ";
|
std::cout << "\n" << termcolor::magenta << "====> ";
|
||||||
std::cout << termcolor::cyan << "Starting test for [";
|
std::cout << termcolor::cyan << "Starting test for [";
|
||||||
std::cout << termcolor::green << m_name;
|
std::cout << termcolor::green << m_name;
|
||||||
std::cout << termcolor::cyan << "]";
|
std::cout << termcolor::cyan << "]";
|
||||||
|
|
@ -446,11 +447,11 @@ namespace ostd
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_dest = __destination;
|
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("cyan").p("Starting test for [");
|
||||||
m_dest->fg("green").p(m_name);
|
m_dest->fg("green").p(m_name);
|
||||||
m_dest->fg("cyan").p("]");
|
m_dest->fg("cyan").p("]");
|
||||||
m_dest->nl().nl().fg("magenta").p(" <====");
|
m_dest->fg("magenta").p(" <====");
|
||||||
m_dest->reset().nl();
|
m_dest->reset().nl();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -530,7 +531,7 @@ namespace ostd
|
||||||
{
|
{
|
||||||
if (m_dest == nullptr)
|
if (m_dest == nullptr)
|
||||||
{
|
{
|
||||||
std::cout << "\n" << termcolor::magenta << "====> ";
|
std::cout << termcolor::magenta << "====> ";
|
||||||
std::cout << termcolor::cyan << "Test for [";
|
std::cout << termcolor::cyan << "Test for [";
|
||||||
std::cout << termcolor::green << m_name;
|
std::cout << termcolor::green << m_name;
|
||||||
std::cout << termcolor::cyan << "] took ";
|
std::cout << termcolor::cyan << "] took ";
|
||||||
|
|
@ -540,7 +541,7 @@ namespace ostd
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_dest->nl().fg("magenta").p("====> ");
|
m_dest->fg("magenta").p("====> ");
|
||||||
m_dest->fg("cyan").p("Test for [");
|
m_dest->fg("cyan").p("Test for [");
|
||||||
m_dest->fg("green").p(m_name);
|
m_dest->fg("green").p(m_name);
|
||||||
m_dest->fg("cyan").p("] took ");
|
m_dest->fg("cyan").p("] took ");
|
||||||
|
|
@ -829,4 +830,24 @@ namespace ostd
|
||||||
}
|
}
|
||||||
return out_string;
|
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 bool loadByteStreamFromFile(const String& filePath, ByteStream& outStream);
|
||||||
static ByteStream stringToByteStream(const String& data);
|
static ByteStream stringToByteStream(const String& data);
|
||||||
static String byteStreamToString(const ByteStream& data);
|
static String byteStreamToString(const ByteStream& data);
|
||||||
|
static String md5(const String& str);
|
||||||
|
|
||||||
//Implemented in <FileSystem.cpp>
|
//Implemented in <FileSystem.cpp>
|
||||||
static std::vector<std::filesystem::path> listFilesInDirectory(const String& directoryPath);
|
static std::vector<std::filesystem::path> listFilesInDirectory(const String& directoryPath);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue