1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-24 20:06:38 +02:00

core: merge functions string_hash_binary and string_hash into a single function string_hash

This commit is contained in:
Sébastien Helleu
2020-03-01 16:41:28 +01:00
parent 1ae2591458
commit c4ef3d6c2e
15 changed files with 305 additions and 675 deletions
+10 -3
View File
@@ -755,7 +755,8 @@ script_repo_sha512sum_file (const char *filename)
{
struct stat st;
FILE *file;
char *data, *hash;
char *data, hash[512 / 8], hash_hexa[((512 / 8) * 2) + 1];
int length_hash;
if (stat (filename, &st) == -1)
return NULL;
@@ -773,11 +774,17 @@ script_repo_sha512sum_file (const char *filename)
}
fclose (file);
hash = weechat_string_hash (data, st.st_size, "sha512");
if (!weechat_string_hash (data, st.st_size, "sha512", hash, &length_hash))
{
free (data);
return NULL;
}
weechat_string_base_encode (16, hash, length_hash, hash_hexa);
weechat_string_tolower (hash_hexa);
free (data);
return hash;
return strdup (hash_hexa);
}
/*