Mercurial > pidgin
comparison libpurple/protocols/jabber/jutil.c @ 25237:401f548e3544
propagate from branch 'im.pidgin.pidgin' (head df6eba32e5b6b34d7483cbfb7e9f2e4c836ac35f)
to branch 'org.darkrain42.pidgin.buddy-add' (head 6831808999a270f8c1a128c7430a73d3dc0bfae2)
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Sun, 21 Dec 2008 18:32:37 +0000 |
parents | 61e0924de04a |
children | 34e4e2ca7db9 |
comparison
equal
deleted
inserted
replaced
25172:125cac3e24ee | 25237:401f548e3544 |
---|---|
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA | 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
19 * | 19 * |
20 */ | 20 */ |
21 #include "internal.h" | 21 #include "internal.h" |
22 #include "account.h" | 22 #include "account.h" |
23 #include "cipher.h" | |
23 #include "conversation.h" | 24 #include "conversation.h" |
25 #include "debug.h" | |
24 #include "server.h" | 26 #include "server.h" |
25 #include "util.h" | 27 #include "util.h" |
26 #include "xmlnode.h" | 28 #include "xmlnode.h" |
27 | 29 |
28 #include "chat.h" | 30 #include "chat.h" |
234 } | 236 } |
235 | 237 |
236 return NULL; | 238 return NULL; |
237 } | 239 } |
238 | 240 |
241 /* The same as purple_util_get_image_checksum, but guaranteed to remain SHA1 */ | |
242 char * | |
243 jabber_calculate_data_sha1sum(gconstpointer data, size_t len) | |
244 { | |
245 PurpleCipherContext *context; | |
246 static gchar digest[41]; | |
247 | |
248 context = purple_cipher_context_new_by_name("sha1", NULL); | |
249 if (context == NULL) | |
250 { | |
251 purple_debug_error("jabber", "Could not find sha1 cipher\n"); | |
252 g_return_val_if_reached(NULL); | |
253 } | |
254 | |
255 /* Hash the data */ | |
256 purple_cipher_context_append(context, data, len); | |
257 if (!purple_cipher_context_digest_to_str(context, sizeof(digest), digest, NULL)) | |
258 { | |
259 purple_debug_error("jabber", "Failed to get SHA-1 digest.\n"); | |
260 g_return_val_if_reached(NULL); | |
261 } | |
262 purple_cipher_context_destroy(context); | |
263 | |
264 return g_strdup(digest); | |
265 } | |
266 |