aboutsummaryrefslogtreecommitdiffstats
path: root/shared/librelational_engine/library.cpp
diff options
context:
space:
mode:
authorMarcos Magueta <maguetamarcos@gmail.com>2026-03-05 23:42:15 -0300
committerMarcos Magueta <maguetamarcos@gmail.com>2026-03-05 23:42:15 -0300
commit8c640a262969ef44cd8bc0e0abe95e2a54f4c3f5 (patch)
tree84f9ddd9e41236fb7a6f540aab07e65db9bc93cb /shared/librelational_engine/library.cpp
parent295c6a5a1f2b0db9d756ffe7bf413553a0c02737 (diff)
downloadSakura-8c640a262969ef44cd8bc0e0abe95e2a54f4c3f5.tar.gz
Sakura-8c640a262969ef44cd8bc0e0abe95e2a54f4c3f5.zip
ocaml re-migration
Diffstat (limited to '')
-rw-r--r--shared/librelational_engine/library.cpp23
1 files changed, 23 insertions, 0 deletions
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 <iostream>
+#include <openssl/sha.h>
+#include <iomanip>
+#include <sstream>
+#include <cstring>
+
+#include <sys/stat.h>
+
+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<int>(hash[i]);
+ std::memcpy(computed_hash, ss.str().c_str(), HASH_SIZE);
+ }
+}