init
authorKristian Fiskerstrand <kf@sumptuouscapital.com>
Wed, 26 Jul 2017 18:45:54 +0000 (20:45 +0200)
committerKristian Fiskerstrand <kf@sumptuouscapital.com>
Wed, 26 Jul 2017 18:45:54 +0000 (20:45 +0200)
Makefile [new file with mode: 0644]
sha256.c [new file with mode: 0644]

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..d89655d
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,24 @@
+TARGET = sha256
+LIBS = -lgcrypt
+CC = gcc
+CFLAGS = -g -Wall
+
+.PHONY: default all clean
+
+default: $(TARGET)
+all: default
+
+OBJECTS = $(patsubst %.c, %.o, $(wildcard *.c))
+HEADERS = $(wildcard *.h)
+
+%.o: %.c $(HEADERS)
+       $(CC) $(CFLAGS) -c $< -o $@
+
+.PRECIOUS: $(TARGET) $(OBJECTS)
+
+$(TARGET): $(OBJECTS)
+       $(CC) $(OBJECTS) -Wall $(LIBS) -o $@
+
+clean:
+       -rm -f *.o
+       -rm -f $(TARGET)
diff --git a/sha256.c b/sha256.c
new file mode 100644 (file)
index 0000000..ed6c428
--- /dev/null
+++ b/sha256.c
@@ -0,0 +1,22 @@
+#include <gcrypt.h>
+#include <stdio.h>
+
+#define HASH_ALGO GCRY_MD_SHA256
+
+void usage(const char *app) {
+       printf("Usage: %s <message>\n", app);
+       exit(1);
+}
+
+int main(int argc, char **argv) {
+       if (argc < 2)
+               usage(argv[0]);
+
+       //int msg_len = strlen (argv[1]);
+
+       char *str = "My string";
+       //igcry_md_hd_t *hctx;
+       //gcry_md_open(hctx, GCRY_MD_SHA256, 0);
+       printf("Dlen: %d\n", gcry_md_get_algo_dlen(GCRY_MD_SHA256));
+       printf("Test\n");       
+}