From 0090695f7d79efa4f50398b55bc59317d1de1d75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Tue, 16 Aug 2022 21:25:30 +0200 Subject: api: add function crypto_hash_file --- doc/en/weechat_plugin_api.en.adoc | 43 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'doc/en') diff --git a/doc/en/weechat_plugin_api.en.adoc b/doc/en/weechat_plugin_api.en.adoc index 6ac9e5440..7f69e8a67 100644 --- a/doc/en/weechat_plugin_api.en.adoc +++ b/doc/en/weechat_plugin_api.en.adoc @@ -3751,6 +3751,49 @@ rc = weechat_crypto_hash (data, strlen (data), "sha256", hash, &hash_size); [NOTE] This function is not available in scripting API. +==== crypto_hash_file + +_WeeChat ≥ 3.7._ + +Compute hash of a file. + +Prototype: + +[source,c] +---- +int weechat_crypto_hash_file (const char *filename, const char *hash_algo, + void *hash, int *hash_size); +---- + +Arguments: + +* _filename_: path and file name +* _hash_algo_: the hash algorithm, see table in function + <> +* _hash_: pointer to the hash variable, which is used to store the resulting hash + (the buffer must be large enough, according to the algorithm, see table in + function <>) +* _hash_size_: pointer to a variable used to store the size of the hash computed + (in bytes) (can be NULL) + +Return value: + +* 1 if OK, 0 if error + +C example: + +[source,c] +---- +char hash[256 / 8]; +int rc, hash_size; +rc = weechat_crypto_hash_file ("/path/to/file", "sha256", hash, &hash_size); +/* rc == 1, hash_size == 32 and hash is a buffer with: + 71 c4 80 df 93 d6 ae 2f 1e fa d1 44 7c 66 c9 52 5e 31 62 18 cf 51 fc 8d 9e d8 32 f2 da f1 8b 73 */ +---- + +[NOTE] +This function is not available in scripting API. + ==== crypto_hash_pbkdf2 _WeeChat ≥ 2.8._ -- cgit v1.2.3