From b804eb4323a01f55727ac48475a9e3c257532ab5 Mon Sep 17 00:00:00 2001 From: Nicolas George Date: Mon, 21 Apr 2014 11:01:10 +0200 Subject: lavu/hash: add hash_final helpers. The helpers use local memory to compute the final hash, making AV_HASH_MAX_SIZE safe to use. --- libavutil/hash.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'libavutil/hash.h') diff --git a/libavutil/hash.h b/libavutil/hash.h index 9bf715e1ac..d4bcbf8cc8 100644 --- a/libavutil/hash.h +++ b/libavutil/hash.h @@ -82,6 +82,28 @@ void av_hash_update(struct AVHashContext *ctx, const uint8_t *src, int len); */ void av_hash_final(struct AVHashContext *ctx, uint8_t *dst); +/** + * Finalize a hash context and compute the actual hash value. + * If size is smaller than the hash size, the hash is truncated; + * if size is larger, the buffer is padded with 0. + */ +void av_hash_final_bin(struct AVHashContext *ctx, uint8_t *dst, int size); + +/** + * Finalize a hash context and compute the actual hash value as a hex string. + * The string is always 0-terminated. + * If size is smaller than 2 * hash_size + 1, the hex string is truncated. + */ +void av_hash_final_hex(struct AVHashContext *ctx, uint8_t *dst, int size); + +/** + * Finalize a hash context and compute the actual hash value as a base64 string. + * The string is always 0-terminated. + * If size is smaller than AV_BASE64_SIZE(hash_size), the base64 string is + * truncated. + */ +void av_hash_final_b64(struct AVHashContext *ctx, uint8_t *dst, int size); + /** * Free hash context. */ -- cgit v1.2.3