about summary refs log tree commit diff stats
path: root/src/common.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-05-21 20:35:01 +0100
committerJames Booth <boothj5@gmail.com>2014-05-21 20:35:01 +0100
commit3c5a73d29ec4de0e22d03e5a1c15af4f096e5cbb (patch)
tree3a7c8ffafbab949ee7a953d281a14b6ceab131e4 /src/common.c
parent1f88ca503259fbe8987b77b4d1379ae20b81dc8d (diff)
downloadprofani-tty-3c5a73d29ec4de0e22d03e5a1c15af4f096e5cbb.tar.gz
Use libgcrypt instead of libgnutls for SHA1 hashing
Diffstat (limited to 'src/common.c')
-rw-r--r--src/common.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/common.c b/src/common.c
index 260dec1a..4ad7f0bd 100644
--- a/src/common.c
+++ b/src/common.c
@@ -31,8 +31,7 @@
 #include <curl/curl.h>
 #include <curl/easy.h>
 #include <glib.h>
-#include <gnutls/gnutls.h>
-#include <gnutls/crypto.h>
+#include <gcrypt.h>
 
 #include "log.h"
 #include "common.h"
@@ -393,16 +392,12 @@ generate_unique_id(char *prefix)
 char *
 sha1_hash(char *str)
 {
-    gnutls_hash_hd_t dig;
-    gnutls_digest_algorithm_t algorithm = GNUTLS_DIG_SHA1;
+   int msg_length = strlen(str);
+   int hash_length = gcry_md_get_algo_dlen(GCRY_MD_SHA1);
+   unsigned char hash[ hash_length ];
+   gcry_md_hash_buffer(GCRY_MD_SHA1, hash, str, msg_length);
 
-    gnutls_hash_init(&dig, algorithm);
-    gnutls_hash(dig, str, strlen(str));
-
-    unsigned char output[20];
-    gnutls_hash_output(dig, output);
-
-    return g_base64_encode(output, sizeof(output));
+   return g_base64_encode(hash, sizeof(hash));
 }
 
 int