Skip to content

Commit 3dbba4b

Browse files
committed
Doc: Fix examples in Librhash docs
1 parent 0e823b4 commit 3dbba4b

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

docs/LIBRHASH.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ Usage examples
3232

3333
int main(int argc, char *argv[]) {
3434
rhash context;
35-
char digest[64];
3635
char output[130];
3736
int i;
37+
const size_t hash_count = 2;
38+
const unsigned hash_ids[hash_count] = { RHASH_MD4, RHASH_MD5 };
3839

3940
rhash_library_init(); /* initialize static data */
4041

41-
context = rhash_init(RHASH_MD4 | RHASH_MD5);
42+
context = rhash_init_multi(hash_count, hash_ids);
4243
if(!context) {
4344
fprintf(stderr, "error: couldn't initialize rhash context\n");
4445
return 1;
@@ -72,7 +73,7 @@ Usage examples
7273
int main(int argc, char *argv[])
7374
{
7475
const char* msg = "message digest";
75-
char digest[64];
76+
unsigned char digest[64];
7677
char output[130];
7778
7879
rhash_library_init(); /* initialize static data */
@@ -96,19 +97,20 @@ Usage examples
9697

9798
```c
9899
#include <errno.h>
100+
#include <string.h>
99101
#include "rhash.h" /* LibRHash interface */
100102

101103
int main(int argc, char *argv[])
102104
{
103105
const char* filepath = "test_file.txt";
104-
char digest[64];
106+
unsigned char digest[64];
105107
char output[130];
106108

107109
rhash_library_init(); /* initialize static data */
108110

109111
int res = rhash_file(RHASH_TTH, filepath, digest);
110112
if(res < 0) {
111-
fprintf(stderr, "LibRHash error: %s: %s\n", filepath, strerror(errno));
113+
fprintf(stderr, "rhash_file() failed for \"%s\": %s\n", filepath, strerror(errno));
112114
return 1;
113115
}
114116

0 commit comments

Comments
 (0)