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 "log.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "tools/p_sha1.h"
|
#include <strophe.h>
|
||||||
|
|
||||||
struct curl_data_t
|
struct curl_data_t
|
||||||
{
|
{
|
||||||
@ -333,17 +333,16 @@ release_is_new(char *found_version)
|
|||||||
char*
|
char*
|
||||||
p_sha1_hash(char *str)
|
p_sha1_hash(char *str)
|
||||||
{
|
{
|
||||||
P_SHA1_CTX ctx;
|
unsigned char *digest = (unsigned char*)malloc(XMPP_SHA1_DIGEST_SIZE);
|
||||||
uint8_t digest[20];
|
assert(digest != NULL);
|
||||||
uint8_t *input = (uint8_t*)malloc(strlen(str) + 1);
|
|
||||||
memcpy(input, str, strlen(str) + 1);
|
|
||||||
|
|
||||||
P_SHA1_Init(&ctx);
|
xmpp_sha1_digest((unsigned char*)str, strlen(str), digest);
|
||||||
P_SHA1_Update(&ctx, input, strlen(str));
|
|
||||||
P_SHA1_Final(&ctx, digest);
|
|
||||||
|
|
||||||
free(input);
|
char *b64 = g_base64_encode(digest, XMPP_SHA1_DIGEST_SIZE);
|
||||||
return g_base64_encode(digest, sizeof(digest));
|
assert(b64 != NULL);
|
||||||
|
free(digest);
|
||||||
|
|
||||||
|
return b64;
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t
|
static size_t
|
||||||
|
Loading…
Reference in New Issue
Block a user