1 /* 2 * Copyright (C) 1993 Branko Lankester 3 * Copyright (C) 1993 Colin Plumb 4 * Copyright (C) 1995 Erik Troan 5 * Copyright (C) 2004 John Ellis 6 * Copyright (C) 2008 - 2016 The Geeqie Team 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 2 of the License, or 11 * (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License along 19 * with this program; if not, write to the Free Software Foundation, Inc., 20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 * 22 * This code implements the MD5 message-digest algorithm. 23 * The algorithm is due to Ron Rivest. This code was 24 * written by Colin Plumb in 1993, no copyright is claimed. 25 * This code is in the public domain; do with it what you wish. 26 * 27 * Equivalent code is available from RSA Data Security, Inc. 28 * This code has been tested against that, and is equivalent, 29 * except that you don't need to include two pages of legalese 30 * with every copy. 31 * 32 * To compute the message digest of a chunk of bytes, declare an 33 * MD5Context structure, pass it to md5_init, call md5_update as 34 * needed on buffers full of bytes, and then call md5_Final, which 35 * will fill a supplied 16-byte array with the digest. 36 */ 37 38 #ifndef MD5_UTIL_H 39 #define MD5_UTIL_H 40 41 #include <glib.h> 42 43 44 typedef struct _MD5Context { 45 guint32 buf[4]; 46 guint32 bits[2]; 47 guchar in[64]; 48 gint doByteReverse; 49 } MD5Context; 50 51 52 /* raw routines */ 53 void md5_init(MD5Context *ctx); 54 void md5_update(MD5Context *ctx, const guchar *buf, guint32 len); 55 void md5_final(MD5Context *ctx, guchar digest[16]); 56 57 /* generate digest from memory buffer */ 58 void md5_get_digest(const guchar *buffer, gint buffer_size, guchar digest[16]); 59 60 /* generate digest from file */ 61 gboolean md5_get_digest_from_file(const gchar *path, guchar digest[16]); 62 63 /* convert digest to/from a NULL terminated text string, in ascii encoding */ 64 gchar *md5_digest_to_text(guchar digest[16]); 65 gboolean md5_digest_from_text(const gchar *text, guchar digest[16]); 66 67 68 #endif /* MD5_UTILS_H */ 69 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ 70