[vlc-devel] [PATCH 02/14] src: add cleaner md5 API

Marvin Scholz epirat07 at gmail.com
Thu Apr 2 00:59:33 CEST 2020


On 2 Apr 2020, at 0:39, Francois Cartegnie wrote:

> Le 01/04/2020 à 21:47, Marvin Scholz a écrit :
>> +static inline void vlc_hash_BinToHex(void *input, size_t size, char 
>> *output)
>> +{
>> +    unsigned char *buffer = input;
>> +
>> +    for (size_t i = 0; i < size; i++) {
>> +        sprintf(&output[i * 2], "%02" PRIx8, buffer[i]);
>> +    }
>
> I don't think bin2hex belongs to a specific API.

Indeed it should probably not be exposed here.

>
>> +vlc_hash_md5_Init
>> +vlc_hash_md5_Update
>> +vlc_hash_md5_Finish
>> +vlc_hash_md5_FinishHex
> If you add a parameter you won't need a new API for a new hash type

I considered it, but a parameter for the hash type  does not really add
a benefit as you still need a specific struct per hash type and there is
not really a nice way to do this in a generic way that I could figure 
out
and was happy with.

Additionally it makes the API a bit weird to use IMO and complicates the
internal implementation part.

>
> -- 
> Francois Cartegnie
> VideoLAN - VLC Developer
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list