gimpmd5.c 1.19 KB
Newer Older
1 2 3 4
/* LIBGIMP - The GIMP Library
 *
 * gimpmd5.c
 *
5
 * Use of this code is deprecated! Use %GChecksum from GLib instead.
6 7 8 9
 */

#include "config.h"

10 11 12
#include <glib-object.h>

#include "gimpmathtypes.h"
13 14 15 16

#include "gimpmd5.h"


17 18 19 20 21 22 23 24 25
/**
 * SECTION: gimpmd5
 * @title: GimpMD5
 * @short_description: The MD5 message-digest algorithm
 *
 * The MD5 message-digest algorithm
 **/


26 27
/**
 * gimp_md5_get_digest:
28
 * @buffer:      byte buffer
29
 * @buffer_size: buffer size (in bytes) or -1 if @buffer is nul-terminated.
30
 * @digest:      16 bytes buffer receiving the hash code.
31
 *
32
 * This function is deprecated! Use %GChecksum from GLib instead.
33
 *
34 35
 * Get the md5 hash of a buffer. The result is put in the 16 bytes
 * buffer @digest. For more information see RFC 1321.
36 37 38 39 40 41
 **/
void
gimp_md5_get_digest (const gchar *buffer,
                     gint         buffer_size,
                     guchar       digest[16])
{
42 43
  GChecksum *checksum;
  gsize      len = 16;
44

45 46
  g_return_if_fail (buffer != NULL);
  g_return_if_fail (digest != NULL);
47

48
  checksum = g_checksum_new (G_CHECKSUM_MD5);
49

50 51
  g_checksum_update (checksum, (const guchar *) buffer, buffer_size);
  g_checksum_get_digest (checksum, digest, &len);
52
  g_checksum_free (checksum);
53
}