Faster md5/1-way encryption?
Alexander Skwar
ASkwar at DigitalProjects.com
Thu Apr 25 03:00:08 EDT 2002
»Mike C. Fletcher« sagte am 2002-04-24 um 18:28:11 -0400 :
> Something that hits me right off the bat:
>
> > md5_zeile = md5.new(zeile).hexdigest()
> > self_Inhalt += md5_zeile + linesep
>
> Would likely be much better as:
>
> myResults = []
> ...
> myResults.append( md5.new(zeile).hexdigest() )
> ...
> myResults = string.join( myResults, os.linesep )
Yes, that makes sense. Thanks!
> Which would save you creating and destroying huge numbers of (at the end
> of processing) very large strings. If you can avoid that last step
Yes, I also noticed, that it gets slower and slower over the time.
> can replace your 'i' counter in that approach (won't be a noticable
> savings, I just hate counters :) ).
Sure, nice idea.
> accurate result as to current position. Unless you really need that
> accuracy, consider just accumulating the length of the lines you're
> processing and adding 1 or 2 each time for the length of os.linesep.
Yes, of course. Good idea here as well.
> MD5 can process gigabytes of information pretty quickly, so I'd be
> surprised if a 100,000 line file is a huge problem.
Yes, that's right, but in the case of processing gigabytes of data,
you're just invoking the digest generation once and not over and over
again; and you're also creating the object once and not 100,000 times.
Thanks for your hints!
Alexander Skwar
--
How to quote: http://learn.to/quote (german) http://quote.6x.to (english)
Homepage: http://www.iso-top.de | Jabber: askwar at a-message.de
iso-top.de - Die günstige Art an Linux Distributionen zu kommen
Uptime: 1 day 1 hour 56 minutes
More information about the Python-list
mailing list