]> Git repositories of Nishi - repoview.git/commitdiff
add md5 for avatar generation
authorNishi <nishi@nishi.boats>
Thu, 22 Aug 2024 02:15:44 +0000 (02:15 +0000)
committerNishi <nishi@nishi.boats>
Thu, 22 Aug 2024 02:15:44 +0000 (02:15 +0000)
git-svn-id: file:///raid/svn-personal/repoview/trunk@33 7e8b2a19-8934-dd40-8cb3-db22cdd5a80f

CGI/Makefile
CGI/md5.c [new file with mode: 0644]
CGI/rv_md5.h [new file with mode: 0644]
Platform/freebsd.mk
Platform/generic.mk
Platform/netbsd.mk

index 47eba8b8d06647a060d2f361951ad741b05f7bfe..28bebfecbc7fe8e06cf540f066cf64c433049ef6 100644 (file)
@@ -5,7 +5,7 @@ include $(PWD)/Platform/$(PLATFORM).mk
 .PHONY: all clean
 .SUFFIXES: .c .o
 
-OBJS = main.o sanity.o version.o util.o query.o page.o sha512.o repo.o $(EXTOBJS)
+OBJS = main.o sanity.o version.o util.o query.o page.o sha512.o md5.o repo.o $(EXTOBJS)
 
 all: repoview.cgi
 
diff --git a/CGI/md5.c b/CGI/md5.c
new file mode 100644 (file)
index 0000000..cdaa2a7
--- /dev/null
+++ b/CGI/md5.c
@@ -0,0 +1,22 @@
+/* $Id$ */
+
+#include "rv_md5.h"
+
+#include <openssl/md5.h>
+
+#include <stdlib.h>
+#include <string.h>
+
+char* rv_md5(const char* string) {
+       const char hex[] = "0123456789abcdef";
+       unsigned char* hash = malloc(MD5_DIGEST_LENGTH);
+       MD5((const unsigned char*)string, strlen(string), hash);
+       char* str = malloc(128 / 4 + 1);
+       int i;
+       for(i = 0; i < 128 / 8; i++) {
+               str[2 * i + 0] = hex[(hash[i] >> 4) & 0xf];
+               str[2 * i + 1] = hex[(hash[i] & 0xf)];
+       }
+       free(hash);
+       return str;
+}
diff --git a/CGI/rv_md5.h b/CGI/rv_md5.h
new file mode 100644 (file)
index 0000000..8f67f48
--- /dev/null
@@ -0,0 +1,8 @@
+/* $Id$ */
+
+#ifndef __RV_MD5_H__
+#define __RV_MD5_H__
+
+char* rv_md5(const char* string);
+
+#endif
index 8f4c2ddd36ccb9e034bcf48c6bffd9e27b90222c..6fe342bb93b3a2d18359ebd44c41471b36fd0440 100644 (file)
@@ -1,6 +1,6 @@
 # $Id$
 
 CC = cc
-CFLAGS = -std=c99 -I /usr/local/include -I /usr/local/include/GraphicsMagick
+CFLAGS = -std=c99 -I /usr/local/include -I /usr/local/include/GraphicsMagick -DOPENSSL_SUPPRESS_DEPRECATED
 LDFLAGS = -L /usr/local/lib
 LIBS = -lcrypto
index f8f14afdd2dae1ede04cbf0e04ab7b4aa34164d8..a9d6d80ceeff66ad169437afa8338aee169a4531 100644 (file)
@@ -1,6 +1,6 @@
 # $Id$
 
 CC = cc
-CFLAGS = -std=c99
+CFLAGS = -std=c99 -DOPENSSL_SUPPRESS_DEPRECATED
 LDFLAGS =
 LIBS = -lcrypto
index 5c2064769f86f5fe243b99c4f2d60a51d88fa2d0..db9f2af5003c972e774df316fee1e981b4f9edf7 100644 (file)
@@ -1,6 +1,6 @@
 # $Id$
 
 CC = cc
-CFLAGS = -std=c99 -I /usr/pkg/include -I /usr/pkg/include/GraphicsMagick
+CFLAGS = -std=c99 -I /usr/pkg/include -I /usr/pkg/include/GraphicsMagick -DOPENSSL_SUPPRESS_DEPRECATED
 LDFLAGS = -L /usr/pkg/lib -Wl,-R/usr/pkg/lib
 LIBS = -lcrypto