aboutsummaryrefslogtreecommitdiffstats
path: root/src/md5.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/md5.c')
-rw-r--r--src/md5.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/md5.c b/src/md5.c
new file mode 100644
index 0000000..e5ab95e
--- /dev/null
+++ b/src/md5.c
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2023, yzrh <yzrh@noema.org>
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#include <stdlib.h>
+
+#include <openssl/md5.h>
+
+int
+strmd5(unsigned char **dst, int *dst_size,
+ const unsigned char * restrict src, int src_size)
+{
+ *dst_size = MD5_DIGEST_LENGTH;
+ *dst = malloc(*dst_size);
+
+ if (*dst == NULL)
+ return 1;
+
+ MD5(src, src_size, *dst);
+
+ return 0;
+}