aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLibravatar Michael Jurkoic <mjjurkoic@gmail.com>2024-03-13 09:00:53 -0500
committerLibravatar Michael Jurkoic <mjjurkoic@gmail.com>2024-03-13 09:00:53 -0500
commitee5b3d683cc480c5eacc8cc0b9fc5f7a197901fd (patch)
tree12626dd960197351dbd5b9cfba3e02fb1e9a1398 /src
parenteb3044b06f6a8275a47478ddd5d8aa10a809422f (diff)
Use SHA256 hashing function for OpenSSL >= 3.0
Diffstat (limited to 'src')
-rw-r--r--src/event.cpp7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/event.cpp b/src/event.cpp
index a95657e..eb6d998 100644
--- a/src/event.cpp
+++ b/src/event.cpp
@@ -1,9 +1,9 @@
#include <ctime>
+#include <openssl/evp.h>
#include <iomanip>
#include <sstream>
#include <string>
#include <nlohmann/json.hpp>
-#include <openssl/sha.h>
#include "nostr.hpp"
@@ -87,10 +87,7 @@ void Event::validate()
string Event::generateId(string serializedData) const
{
unsigned char hash[SHA256_DIGEST_LENGTH];
- SHA256_CTX sha256;
- SHA256_Init(&sha256);
- SHA256_Update(&sha256, serializedData.c_str(), serializedData.length());
- SHA256_Final(hash, &sha256);
+ EVP_Digest(serializedData.c_str(), serializedData.length(), hash, NULL, EVP_sha256(), NULL);
stringstream ss;
for (int i = 0; i < SHA256_DIGEST_LENGTH; i++)