File: gimpmd5.c

package info (click to toggle)
gimp 2.8.14-1+deb8u2
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 153,252 kB
  • sloc: ansic: 703,816; sh: 11,580; makefile: 10,943; lisp: 10,844; python: 3,708; perl: 3,411; xml: 1,307; yacc: 588; lex: 342
file content (52 lines) | stat: -rw-r--r-- 1,214 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* LIBGIMP - The GIMP Library
 *
 * gimpmd5.c
 *
 * Use of this code is deprecated! Use %GChecksum from GLib instead.
 */

#include "config.h"

#include <glib.h>

#undef GIMP_DISABLE_DEPRECATED
#include "gimpmd5.h"


/**
 * SECTION: gimpmd5
 * @title: GimpMD5
 * @short_description: The MD5 message-digest algorithm
 *
 * The MD5 message-digest algorithm
 **/


/**
 * gimp_md5_get_digest:
 * @buffer:      byte buffer
 * @buffer_size: buffer size (in bytes) or -1 if @buffer is nul-terminated.
 * @digest:      16 bytes buffer receiving the hash code.
 *
 * This function is deprecated! Use %GChecksum from GLib instead.
 *
 * Get the md5 hash of a buffer. The result is put in the 16 bytes
 * buffer @digest. For more information see RFC 1321.
 **/
void
gimp_md5_get_digest (const gchar *buffer,
                     gint         buffer_size,
                     guchar       digest[16])
{
  GChecksum *checksum;
  gsize      len = 16;

  g_return_if_fail (buffer != NULL);
  g_return_if_fail (digest != NULL);

  checksum = g_checksum_new (G_CHECKSUM_MD5);

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