Questioning MD5 hash generation for ArtURL

This forum is about all development around libVLC.
WallyZ21
New Cone
New Cone
Posts: 2
Joined: 26 Feb 2015 01:39

Questioning MD5 hash generation for ArtURL

Postby WallyZ21 » 26 Feb 2015 02:00

I hope I'm in the correct forum with this post!

I'm trying to validate the generated MD5 hash key create by ArtCacheGetDirPath that is used to create the
ArtURL directories/folders.

However I cannot replicate the generated hash using md5sum when using the same input string.

I include the code for ArtCacheGetDirPath with a couple of my printf (debug) lines:

Code: Select all

static char* ArtCacheGetDirPath( const char *psz_arturl, const char *psz_artist, const char *psz_album, const char *psz_title ) { char *psz_dir; char *psz_cachedir = config_GetUserDir(VLC_CACHE_DIR); if( !EMPTY_STR(psz_artist) && !EMPTY_STR(psz_album) ) { char *psz_album_sanitized = strdup( psz_album ); filename_sanitize( psz_album_sanitized ); char *psz_artist_sanitized = strdup( psz_artist ); filename_sanitize( psz_artist_sanitized ); if( asprintf( &psz_dir, "%s" DIR_SEP "art" DIR_SEP "artistalbum" DIR_SEP "%s" DIR_SEP "%s", psz_cachedir, psz_artist_sanitized, psz_album_sanitized ) == -1 ) psz_dir = NULL; free( psz_album_sanitized ); free( psz_artist_sanitized ); } else { /* If artist or album are missing, cache by art download URL. * If the URL is an attachment://, add the title to the cache name. * It will be md5 hashed to form a valid cache filename. * We assume that psz_arturl is always the download URL and not the * already hashed filename. * (We should never need to call this function if art has already been * downloaded anyway). */ struct md5_s md5; InitMD5( &md5 ); AddMD5( &md5, psz_arturl, strlen( psz_arturl ) ); printf("psz_arturl >%s<\n", psz_arturl); if( !strncmp( psz_arturl, "attachment://", 13 ) ) { AddMD5( &md5, psz_title, strlen( psz_title ) ); printf("psz_title >%s<\n", psz_title); } EndMD5( &md5 ); char * psz_arturl_sanitized = psz_md5_hash( &md5 ); printf("psz_artual_sanitized:%s\n", psz_arturl_sanitized); if( asprintf( &psz_dir, "%s" DIR_SEP "art" DIR_SEP "arturl" DIR_SEP "%s", psz_cachedir, psz_arturl_sanitized ) == -1 ) psz_dir = NULL; free( psz_arturl_sanitized ); } free( psz_cachedir ); return psz_dir; }
When I run vlc and open a youtube video I receive this output:

wallyz@EP45-DS3:~/Downloads/VLC/vlc-2.1.5$ ./vlc
VLC media player 2.1.5 Rincewind (revision 2.1.4-49-gdab6cb5)
[0x1dc0428] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
[0x1dd4db8] main playlist: stopping playback
psz_arturl >https://i.ytimg.com/vi/rO5L_luK1LA/maxresdefault.jpg<
psz_artual_sanitized:db17a3d0c87a9d2a00beefe231aaa3ba
[0x1dd4db8] main playlist: stopping playback
psz_arturl >https://i.ytimg.com/vi/rO5L_luK1LA/maxresdefault.jpg<
psz_artual_sanitized:db17a3d0c87a9d2a00beefe231aaa3ba
psz_arturl >http://i.ytimg.com/vi/rO5L_luK1LA/default.jpg<
psz_artual_sanitized:b0f2893482a1768ccb4fe515b7d17d1e
psz_arturl >http://i.ytimg.com/vi/rO5L_luK1LA/default.jpg<
psz_artual_sanitized:b0f2893482a1768ccb4fe515b7d17d1e
Fontconfig warning: FcPattern object size does not accept value "0"
Fontconfig warning: FcPattern object size does not accept value "0"
Fontconfig warning: FcPattern object size does not accept value "0"
Fontconfig warning: FcPattern object size does not accept value "0"
[0x7f5014001248] main vout display error: Failed to resize display
^Cwallyz@EP45-DS3:~/Downloads/VLC/vlc-2.1.5$ echo "https://i.ytimg.com/vi/rO5L_luK1LA/maxrdefault.jpg" | md5sum
b1a169735e9201e972a58e1ffcaca8bd -
wallyz@EP45-DS3:~/Downloads/VLC/vlc-2.1.5$

The ArtURL is "https://i.ytimg.com/vi/rO5L_luK1LA/maxresdefault.jpg"
which generates the VLC MD5 db17a3d0c87a9d2a00beefe231aaa3ba
however md5sum generates b1a169735e9201e972a58e1ffcaca8bd

Why the discrepancy?

Can anyone help?

Rémi Denis-Courmont
Developer
Developer
Posts: 15268
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Questioning MD5 hash generation for ArtURL

Postby Rémi Denis-Courmont » 26 Feb 2015 09:36

The title?
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

WallyZ21
New Cone
New Cone
Posts: 2
Joined: 26 Feb 2015 01:39

Re: Questioning MD5 hash generation for ArtURL

Postby WallyZ21 » 03 Mar 2015 04:15

The Title doesn't appear to have been used in the construction of the MD5 string otherwise the printf in the conditional code (below) would have displayed it.

if( !strncmp( psz_arturl, "attachment://", 13 ) )
{
AddMD5( &md5, psz_title, strlen( psz_title ) );
printf("psz_title >%s<\n", psz_title);
}


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 41 guests