mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Use libstrophe sha1 functions
Using libstrophes sha1 functions in p_sha1_hash() to get rid of the p_sha1.c dependency. Relates to https://github.com/boothj5/profanity/issues/882
This commit is contained in:
parent
82f77a9285
commit
dcc249a616
19
src/common.c
19
src/common.c
@ -55,7 +55,7 @@
|
||||
|
||||
#include "log.h"
|
||||
#include "common.h"
|
||||
#include "tools/p_sha1.h"
|
||||
#include <strophe.h>
|
||||
|
||||
struct curl_data_t
|
||||
{
|
||||
@ -333,17 +333,16 @@ release_is_new(char *found_version)
|
||||
char*
|
||||
p_sha1_hash(char *str)
|
||||
{
|
||||
P_SHA1_CTX ctx;
|
||||
uint8_t digest[20];
|
||||
uint8_t *input = (uint8_t*)malloc(strlen(str) + 1);
|
||||
memcpy(input, str, strlen(str) + 1);
|
||||
unsigned char *digest = (unsigned char*)malloc(XMPP_SHA1_DIGEST_SIZE);
|
||||
assert(digest != NULL);
|
||||
|
||||
P_SHA1_Init(&ctx);
|
||||
P_SHA1_Update(&ctx, input, strlen(str));
|
||||
P_SHA1_Final(&ctx, digest);
|
||||
xmpp_sha1_digest((unsigned char*)str, strlen(str), digest);
|
||||
|
||||
free(input);
|
||||
return g_base64_encode(digest, sizeof(digest));
|
||||
char *b64 = g_base64_encode(digest, XMPP_SHA1_DIGEST_SIZE);
|
||||
assert(b64 != NULL);
|
||||
free(digest);
|
||||
|
||||
return b64;
|
||||
}
|
||||
|
||||
static size_t
|
||||
|
Loading…
Reference in New Issue
Block a user