1ZDIGEST(3)                        CZMQ Manual                       ZDIGEST(3)
2
3
4

NAME

6       zdigest - Class for provides hashing functions (SHA-1 at present)
7

SYNOPSIS

9       //  This is a stable class, and may not change except for emergencies. It
10       //  is provided in stable builds.
11       //  Constructor - creates new digest object, which you use to build up a
12       //  digest by repeatedly calling zdigest_update() on chunks of data.
13       CZMQ_EXPORT zdigest_t *
14           zdigest_new (void);
15
16       //  Destroy a digest object
17       CZMQ_EXPORT void
18           zdigest_destroy (zdigest_t **self_p);
19
20       //  Add buffer into digest calculation
21       CZMQ_EXPORT void
22           zdigest_update (zdigest_t *self, const byte *buffer, size_t length);
23
24       //  Return final digest hash data. If built without crypto support,
25       //  returns NULL.
26       CZMQ_EXPORT const byte *
27           zdigest_data (zdigest_t *self);
28
29       //  Return final digest hash size
30       CZMQ_EXPORT size_t
31           zdigest_size (zdigest_t *self);
32
33       //  Return digest as printable hex string; caller should not modify nor
34       //  free this string. After calling this, you may not use zdigest_update()
35       //  on the same digest. If built without crypto support, returns NULL.
36       CZMQ_EXPORT char *
37           zdigest_string (zdigest_t *self);
38
39       //  Self test of this class.
40       CZMQ_EXPORT void
41           zdigest_test (bool verbose);
42
43       Please add '@interface' section in './../src/zdigest.c'.
44

DESCRIPTION

46       The zdigest class generates a hash from zchunks of data. The current
47       algorithm is SHA-1, chosen for speed. We are aiming to generate a
48       unique digest for a file, and there are no security issues in this use
49       case.
50
51       The current code depends on OpenSSL, which might be replaced by hard
52       coded SHA-1 implementation to reduce build dependencies.
53

EXAMPLE

55       From zdigest_test method.
56
57           byte *buffer = (byte *) zmalloc (1024);
58           memset (buffer, 0xAA, 1024);
59
60           zdigest_t *digest = zdigest_new ();
61           assert (digest);
62           zdigest_update (digest, buffer, 1024);
63           const byte *data = zdigest_data (digest);
64           assert (data [0] == 0xDE);
65           assert (data [1] == 0xB2);
66           assert (data [2] == 0x38);
67           assert (data [3] == 0x07);
68           assert (streq (zdigest_string (digest),
69                          "DEB23807D4FE025E900FE9A9C7D8410C3DDE9671"));
70           zdigest_destroy (&digest);
71           freen (buffer);
72
73           #if defined (__WINDOWS__)
74           zsys_shutdown();
75           #endif
76
77

AUTHORS

79       The czmq manual was written by the authors in the AUTHORS file.
80

RESOURCES

82       Main web site:
83
84       Report bugs to the email <zeromq-dev@lists.zeromq.org[1]>
85
87       Copyright (c) the Contributors as noted in the AUTHORS file. This file
88       is part of CZMQ, the high-level C binding for 0MQ:
89       http://czmq.zeromq.org. This Source Code Form is subject to the terms
90       of the Mozilla Public License, v. 2.0. If a copy of the MPL was not
91       distributed with this file, You can obtain one at
92       http://mozilla.org/MPL/2.0/. LICENSE included with the czmq
93       distribution.
94

NOTES

96        1. zeromq-dev@lists.zeromq.org
97           mailto:zeromq-dev@lists.zeromq.org
98
99
100
101CZMQ 4.2.1                        10/31/2019                        ZDIGEST(3)
Impressum