Using different hash algorithm in purple_util_get_image_checksum()
Elliott Sales de Andrade
qulogic at pidgin.im
Sat Jul 4 19:08:37 EDT 2009
On Sat, Jul 4, 2009 at 1:33 AM, Paul Aurich <paul at darkrain42.org> wrote:
> And Richard Laager spoke on 07/01/2009 10:41 PM, saying:
> > On Wed, 2009-07-01 at 01:29 -0700, Mark Doliner wrote:
> >> Vijay from Meebo tells me that he seems to
> >> remember the sha-1 implementation in glib 2.16 is much faster than the
> >> one in our cipher.c.
> > If this is true and it would be possible, it'd be nice if we just called
> > that from our cipher API when libpurple is built against glib >= 2.16.
> I've attached a patch that will conditionally use Glib for MD5, SHA1, and
> SHA256 when available. `make check` passes with all three and it seems to
> work fine.
`make check` works for me as well. I can also login to XMPP (MD5?) and MSN
(SHA1 in HMAC).
> In a very simplistic benchmark, I loaded the largest image in my
> .purple/icons/ (32KiB) and calculated the SHA1sum 100,000 times (and stuck
> a g_str_equal() in there just to make sure gcc didn't get cute with me). On
> my AMD Athlon 64 4400+, the cipher.c implementation took about 41 seconds
> and glib's implementation took about 14 seconds.
> Anyone have any problems with my checking this in? The only thing left to
> do is deal with the issue in adding data to the checksum, where GChecksum
> uses a gssize and we use a gsize for the length, which will be bad when I
> decide I want to use Pidgin to calculate the checksum for my 3GB file
> (after I dig up a 32-bit system).
I think this works (though I didn't try any 3GiB files):
while (len >= G_MAXSSIZE)
g_checksum_update(checksum, data, G_MAXSSIZE);
len -= G_MAXSSIZE;
data += G_MAXSSIZE;
g_checksum_update(checksum, data, len);
> Devel mailing list
> Devel at pidgin.im
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Devel