X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=include%2Fvlc_md5.h;h=46f10f01439edbcc8bad45673cc302039b76dd5b;hb=d253749f68a85d8c720e66e4a0f7ad9693ba84e3;hp=7d61eca35d2c42af509cf88ab83f43f79f4f4bc6;hpb=1acf84b10b54427282a81fcf4ec2d560d7e8bb55;p=vlc diff --git a/include/vlc_md5.h b/include/vlc_md5.h index 7d61eca35d..46f10f0143 100644 --- a/include/vlc_md5.h +++ b/include/vlc_md5.h @@ -1,8 +1,8 @@ /***************************************************************************** * vlc_md5.h: MD5 hash ***************************************************************************** - * Copyright (C) 2004-2005 VideoLAN - * $Id: drms.c 10101 2005-03-02 16:47:31Z robux4 $ + * Copyright (C) 2004-2005 the VideoLAN team + * $Id$ * * Authors: Jon Lech Johansen * Sam Hocevar @@ -19,7 +19,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ #ifndef _VLC_MD5_H @@ -39,8 +39,31 @@ struct md5_s }; VLC_EXPORT(void, InitMD5, ( struct md5_s * ) ); -VLC_EXPORT(void, AddMD5, ( struct md5_s *, const uint8_t *, uint32_t ) ); +VLC_EXPORT(void, AddMD5, ( struct md5_s *, const void *, size_t ) ); VLC_EXPORT(void, EndMD5, ( struct md5_s * ) ); -VLC_EXPORT(void, Digest, ( struct md5_s *, uint32_t * ) ); + +/** + * Returns a char representation of the md5 hash, as shown by UNIX md5 or + * md5sum tools. + */ +static inline char * psz_md5_hash( struct md5_s *md5_s ) +{ + char *psz = malloc( 33 ); /* md5 string is 32 bytes + NULL character */ + if( !psz ) return NULL; + + int i; + for ( i = 0; i < 4; i++ ) + { + sprintf( &psz[8*i], "%02x%02x%02x%02x", + md5_s->p_digest[i] & 0xff, + ( md5_s->p_digest[i] >> 8 ) & 0xff, + ( md5_s->p_digest[i] >> 16 ) & 0xff, + md5_s->p_digest[i] >> 24 + ); + } + psz[32] = '\0'; + + return psz; +} #endif