2 * Copyright (C) 2013 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
4 * This file is part of FFmpeg.
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
29 * Allocate a hash context for the algorithm specified by name.
31 * @return >= 0 for success, a negative error code for failure
32 * @note The context is not initialized, you must call av_hash_init().
34 int av_hash_alloc(struct AVHashContext **ctx, const char *name);
37 * Get the names of available hash algorithms.
39 * This function can be used to enumerate the algorithms.
41 * @param i index of the hash algorithm, starting from 0
42 * @return a pointer to a static string or NULL if i is out of range
44 const char *av_hash_names(int i);
47 * Get the name of the algorithm corresponding to the given hash context.
49 const char *av_hash_get_name(const struct AVHashContext *ctx);
52 * Maximum value that av_hash_get_size will currently return.
54 * You can use this if you absolutely want or need to use static allocation
55 * and are fine with not supporting hashes newly added to libavutil without
57 * Note that you still need to check against av_hash_get_size, adding new hashes
58 * with larger sizes will not be considered an ABI change and should not cause
59 * your code to overflow a buffer.
61 #define AV_HASH_MAX_SIZE 64
64 * Get the size of the resulting hash value in bytes.
66 * The pointer passed to av_hash_final have space for at least this many bytes.
68 int av_hash_get_size(const struct AVHashContext *ctx);
71 * Initialize or reset a hash context.
73 void av_hash_init(struct AVHashContext *ctx);
76 * Update a hash context with additional data.
78 void av_hash_update(struct AVHashContext *ctx, const uint8_t *src, int len);
81 * Finalize a hash context and compute the actual hash value.
83 void av_hash_final(struct AVHashContext *ctx, uint8_t *dst);
86 * Finalize a hash context and compute the actual hash value.
87 * If size is smaller than the hash size, the hash is truncated;
88 * if size is larger, the buffer is padded with 0.
90 void av_hash_final_bin(struct AVHashContext *ctx, uint8_t *dst, int size);
93 * Finalize a hash context and compute the actual hash value as a hex string.
94 * The string is always 0-terminated.
95 * If size is smaller than 2 * hash_size + 1, the hex string is truncated.
97 void av_hash_final_hex(struct AVHashContext *ctx, uint8_t *dst, int size);
100 * Finalize a hash context and compute the actual hash value as a base64 string.
101 * The string is always 0-terminated.
102 * If size is smaller than AV_BASE64_SIZE(hash_size), the base64 string is
105 void av_hash_final_b64(struct AVHashContext *ctx, uint8_t *dst, int size);
110 void av_hash_freep(struct AVHashContext **ctx);
112 #endif /* AVUTIL_HASH_H */