From 8c640a262969ef44cd8bc0e0abe95e2a54f4c3f5 Mon Sep 17 00:00:00 2001 From: Marcos Magueta Date: Thu, 5 Mar 2026 23:42:15 -0300 Subject: ocaml re-migration --- shared/librelational_engine/CMakeLists.txt | 11 +++++++++++ shared/librelational_engine/library.cpp | 23 +++++++++++++++++++++++ shared/librelational_engine/library.h | 8 ++++++++ 3 files changed, 42 insertions(+) create mode 100644 shared/librelational_engine/CMakeLists.txt create mode 100644 shared/librelational_engine/library.cpp create mode 100644 shared/librelational_engine/library.h (limited to 'shared') diff --git a/shared/librelational_engine/CMakeLists.txt b/shared/librelational_engine/CMakeLists.txt new file mode 100644 index 0000000..22c8444 --- /dev/null +++ b/shared/librelational_engine/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.29) +project(relational_engine) + +include_directories($ENV{LIBRESSL_INCLUDE_PATH}) + +add_library(relational_engine SHARED library.cpp) + +target_link_libraries(relational_engine + $ENV{LIBRESSL_LIB_PATH}/libssl.$ENV{OS_LIB_EXTENSION} + $ENV{LIBRESSL_LIB_PATH}/libcrypto.$ENV{OS_LIB_EXTENSION} +) \ No newline at end of file diff --git a/shared/librelational_engine/library.cpp b/shared/librelational_engine/library.cpp new file mode 100644 index 0000000..a9b4c81 --- /dev/null +++ b/shared/librelational_engine/library.cpp @@ -0,0 +1,23 @@ +#include +#include +#include +#include +#include + +#include + +extern "C" { +#include "library.h" + + extern void compute_hash(char* computed_hash, const char *content) { + unsigned char hash[SHA256_DIGEST_LENGTH]; + SHA256_CTX sha256; + SHA256_Init(&sha256); + SHA256_Update(&sha256, content, std::strlen(content)); + SHA256_Final(hash, &sha256); + std::stringstream ss; + for (int i = 0; i < SHA256_DIGEST_LENGTH; i++) + ss << std::hex << std::setw(2) << std::setfill('0') << static_cast(hash[i]); + std::memcpy(computed_hash, ss.str().c_str(), HASH_SIZE); + } +} diff --git a/shared/librelational_engine/library.h b/shared/librelational_engine/library.h new file mode 100644 index 0000000..cae22cb --- /dev/null +++ b/shared/librelational_engine/library.h @@ -0,0 +1,8 @@ +#ifndef RELATIONAL_ENGINE_LIBRARY_H +#define RELATIONAL_ENGINE_LIBRARY_H + +#define HASH_SIZE 64 + +extern void compute_hash(char*, const char*); + +#endif //RELATIONAL_ENGINE_LIBRARY_H -- cgit v1.2.3