summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/md5calc.c26
-rw-r--r--src/common/md5calc.h7
-rw-r--r--src/map/log.c9
3 files changed, 39 insertions, 3 deletions
diff --git a/src/common/md5calc.c b/src/common/md5calc.c
index 3f9ccdc41..bbace132b 100644
--- a/src/common/md5calc.c
+++ b/src/common/md5calc.c
@@ -29,6 +29,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <openssl/sha.h>
/** @file
* Implementation of the md5 interface.
@@ -259,6 +260,29 @@ static void md5_salt(int len, char *output)
}
+/*******************************************************************************/
+// SHA256 wrappers [TMW2]
+void sha256_hash_string (unsigned char hash[SHA256_DIGEST_LENGTH], char outputBuffer[65])
+{
+ int i = 0;
+
+ for(i = 0; i < SHA256_DIGEST_LENGTH; i++)
+ {
+ sprintf(outputBuffer + (i * 2), "%02x", hash[i]);
+ }
+
+ outputBuffer[64] = 0;
+}
+
+void sha256_hash (const char* message, char* outputBuffer)
+{
+ unsigned char obuf[SHA256_DIGEST_LENGTH];
+ SHA256((const unsigned char*)(message), strlen(message), obuf);
+ sha256_hash_string(obuf, outputBuffer);
+}
+
+/*******************************************************************************/
+
/**
* Interface base initialization.
*/
@@ -268,4 +292,6 @@ void md5_defaults(void)
md5->binary = md5_buf2binary;
md5->string = md5_string;
md5->salt = md5_salt;
+ md5->sha256 = sha256_hash;
}
+
diff --git a/src/common/md5calc.h b/src/common/md5calc.h
index bd06f1fbc..26e4fa567 100644
--- a/src/common/md5calc.h
+++ b/src/common/md5calc.h
@@ -55,6 +55,13 @@ struct md5_interface {
* @param[out] output The output buffer (at least len bytes available).
*/
void (*salt) (int len, char *output);
+
+ /**
+ * Generates a sha256 hash
+ */
+ void (*sha256) (const char* message, char* outputBuffer);
+
+
};
#ifdef HERCULES_CORE
diff --git a/src/map/log.c b/src/map/log.c
index 85cdac84a..5676730dc 100644
--- a/src/map/log.c
+++ b/src/map/log.c
@@ -486,10 +486,13 @@ static void log_chat(e_log_chat_type type, int type_id, int src_charid, int src_
if (dst_charname == NULL)
dst_charname = "";
- // Hash the message, we don't care with it
+ // Hash the message, we don't care with it (FIXME)
+ //unsigned char obuf[SHA256_DIGEST_LENGTH];
+ //SHA256((const unsigned char*)(message), strlen(message), obuf);
char *md5str;
- md5str = (char *)aMalloc((32+1)*sizeof(char));
- md5->string(message, md5str);
+ md5str = (char *)aMalloc((64+1)*sizeof(char));
+ md5->sha256(message, md5str);
+ //md5str = (char *)obuf;
logs->chat_sub(type,type_id,src_charid,src_accid,mapname,x,y,dst_charname,md5str);
}