You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

gchecksum.h 2.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* gchecksum.h - data hashing functions
  2. *
  3. * Copyright (C) 2007 Emmanuele Bassi <ebassi@gnome.org>
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Library General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2 of the License, or (at your option) any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Library General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Library General Public
  16. * License along with this library; if not, write to the
  17. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  18. * Boston, MA 02111-1307, USA.
  19. */
  20. #ifndef __G_CHECKSUM_H__
  21. #define __G_CHECKSUM_H__
  22. #include <glib.h>
  23. G_BEGIN_DECLS
  24. /**
  25. * GChecksumType:
  26. * @G_CHECKSUM_MD5: Use the MD5 hashing algorithm
  27. * @G_CHECKSUM_SHA1: Use the SHA-1 hashing algorithm
  28. * @G_CHECKSUM_SHA256: Use the SHA-256 hashing algorithm
  29. *
  30. * The hashing algorithm to be used by #GChecksum when performing the
  31. * digest of some data.
  32. *
  33. * Note that the #GChecksumType enumeration may be extended at a later
  34. * date to include new hashing algorithm types.
  35. *
  36. * Since: 2.16
  37. */
  38. typedef enum {
  39. G_CHECKSUM_MD5,
  40. G_CHECKSUM_SHA1,
  41. G_CHECKSUM_SHA256
  42. } GChecksumType;
  43. /**
  44. * GChecksum:
  45. *
  46. * An opaque structure representing a checksumming operation.
  47. * To create a new GChecksum, use g_checksum_new(). To free
  48. * a GChecksum, use g_checksum_free().
  49. *
  50. * Since: 2.16
  51. */
  52. typedef struct _GChecksum GChecksum;
  53. gssize g_checksum_type_get_length (GChecksumType checksum_type);
  54. GChecksum * g_checksum_new (GChecksumType checksum_type);
  55. void g_checksum_reset (GChecksum *checksum);
  56. GChecksum * g_checksum_copy (const GChecksum *checksum);
  57. void g_checksum_free (GChecksum *checksum);
  58. void g_checksum_update (GChecksum *checksum,
  59. const guchar *data,
  60. gssize length);
  61. G_CONST_RETURN gchar *g_checksum_get_string (GChecksum *checksum);
  62. void g_checksum_get_digest (GChecksum *checksum,
  63. guint8 *buffer,
  64. gsize *digest_len);
  65. gchar *g_compute_checksum_for_data (GChecksumType checksum_type,
  66. const guchar *data,
  67. gsize length);
  68. gchar *g_compute_checksum_for_string (GChecksumType checksum_type,
  69. const gchar *str,
  70. gssize length);
  71. G_END_DECLS
  72. #endif /* __G_CHECKSUM_H__ */