Browse Source

add md5hash func

balbekova 5 years ago
parent
commit
9190fa4355
2 changed files with 33 additions and 0 deletions
  1. 20 0
      modules/common/hash.c
  2. 13 0
      modules/common/hash.h

+ 20 - 0
modules/common/hash.c

@@ -0,0 +1,20 @@
+/*
+ * hash.c
+ *
+ *  Created on: 06.12.2016
+ *      Author: pavel
+ */
+
+
+#include "lwip/arch.h"
+#include "mbedtls/md5.h"
+#include "hash.h"
+
+
+void md5hash(unsigned char *hash, unsigned char *msg, unsigned int msg_len) {
+	mbedtls_md5_context mdContext;
+
+	mbedtls_md5_starts(&mdContext);
+	mbedtls_md5_update(&mdContext, msg, msg_len);
+	mbedtls_md5_finish(&mdContext, hash);
+}

+ 13 - 0
modules/common/hash.h

@@ -0,0 +1,13 @@
+/*
+ * hash.h
+ *
+ *  Created on: 06.12.2016
+ *      Author: pavel
+ */
+
+#ifndef HASH_H_
+#define HASH_H_
+
+void md5hash(unsigned char *hash, unsigned char *msg, unsigned int msg_len);
+
+#endif /* HASH_H_ */