Last change
on this file since 4a9c6b0 was
5ebff60,
checked in by dequis <dx@…>, at 2015-02-20T22:50:54Z
|
Reindent everything to K&R style with tabs
Used uncrustify, with the configuration file in ./doc/uncrustify.cfg
Commit author set to "Indent <please@…>" so that it's easier to
skip while doing git blame.
|
-
Property mode set to
100644
|
File size:
928 bytes
|
Line | |
---|
1 | #include "md5.h" |
---|
2 | |
---|
3 | /* Creates a new GChecksum in ctx */ |
---|
4 | void md5_init(md5_state_t *ctx) |
---|
5 | { |
---|
6 | *ctx = g_checksum_new(G_CHECKSUM_MD5); |
---|
7 | } |
---|
8 | |
---|
9 | /* Wrapper for g_checksum_update */ |
---|
10 | void md5_append(md5_state_t *ctx, const guint8 *buf, unsigned int len) |
---|
11 | { |
---|
12 | g_checksum_update(*ctx, buf, len); |
---|
13 | } |
---|
14 | |
---|
15 | /* Wrapper for g_checksum_get_digest |
---|
16 | * Also takes care of g_checksum_free(), since it can't be reused anyway |
---|
17 | * (the GChecksum is closed after get_digest) */ |
---|
18 | void md5_finish(md5_state_t *ctx, guint8 digest[MD5_HASH_SIZE]) |
---|
19 | { |
---|
20 | gsize digest_len = MD5_HASH_SIZE; |
---|
21 | |
---|
22 | g_checksum_get_digest(*ctx, digest, &digest_len); |
---|
23 | g_checksum_free(*ctx); |
---|
24 | } |
---|
25 | |
---|
26 | /* Variant of md5_finish that copies the GChecksum |
---|
27 | * and finishes that one instead of the original */ |
---|
28 | void md5_digest_keep(md5_state_t *ctx, guint8 digest[MD5_HASH_SIZE]) |
---|
29 | { |
---|
30 | md5_state_t copy = g_checksum_copy(*ctx); |
---|
31 | |
---|
32 | md5_finish(©, digest); |
---|
33 | } |
---|
34 | |
---|
35 | void md5_free(md5_state_t *ctx) |
---|
36 | { |
---|
37 | g_checksum_free(*ctx); |
---|
38 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.