<div dir="ltr">I had asked this question before, but there was some hesitation based on the licensing of Mono. I'm not sure if that is an issue anymore.</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Feb 27, 2014 at 12:16 PM, Pawel Jasinski <span dir="ltr"><<a href="mailto:pawel.jasinski@gmail.com" target="_blank">pawel.jasinski@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Is there any reason not to use code out of mono?<br>
It looks like it supports SHA2 and RIPEMD160.<br>
<a href="https://bugzilla.xamarin.com/show_bug.cgi?id=11703" target="_blank">https://bugzilla.xamarin.com/show_bug.cgi?id=11703</a><br>
<div class="HOEnZb"><div class="h5"><br>
On Thu, Feb 27, 2014 at 2:10 PM, Markus Schaber <<a href="mailto:m.schaber@codesys.com">m.schaber@codesys.com</a>> wrote:<br>
> Hi,<br>
><br>
> Von: Jeff Hardy [mailto:<a href="mailto:jdhardy@gmail.com">jdhardy@gmail.com</a>]<br>
>> On Thu, Feb 27, 2014 at 11:11 AM, Markus Schaber <<a href="mailto:m.schaber@codesys.com">m.schaber@codesys.com</a>><br>
>> wrote:<br>
>> > Hi,<br>
>> ><br>
>> > I'm just trying to sum it up:<br>
>> ><br>
>> > 1) The current code:<br>
>> >    - High memory usage.<br>
>> >    - High load on the large object heap.<br>
>> >    - Limited by the available amount of memory (which might be considered a<br>
>> violation of the Python API).<br>
>> >    - High CPU usage when used incrementally (quadratic to the number of<br>
>> blocks added).<br>
>> ><br>
>> > 2) Optimizing with MemoryStream and lazy calculation:<br>
>> >    - High memory usage.<br>
>> >    - High load on the large object heap.<br>
>> >    - Limited by the available amount of memory (which might be considered a<br>
>> violation of the Python API).<br>
>> >    + Optimal CPU usage when the hash is only fetched once.<br>
>> >    ± Better than current code, but still not optimal when hash is<br>
>> incrementally fetched several times.<br>
>> ><br>
>> > 3) Optimizing with jagged arrays and lazy calculation:<br>
>> >    - High memory usage.<br>
>> >    + Improved or no impact on the large object heap (depending on the exact<br>
>> implementation)<br>
>> >    - Limited by the available amount of memory (which might be considered a<br>
>> violation of the Python API).<br>
>> >    + Optimal CPU usage when the hash is only fetched once.<br>
>> >    ± Better than current code, but still not optimal when hash is<br>
>> incrementally fetched several times.<br>
>> ><br>
>> > 4) Using the existing .NET incremental APIs<br>
>> >    + Low, constant memory usage.<br>
>> >    + No impact on the large object heap.<br>
>> >    + No limit of data length by the amount of memory.<br>
>> >    + Optimal CPU usage when the hash is only fetched once.<br>
>> >    - Breaks when hash is incrementally fetched several times (which likely<br>
>> is a violation of the Python API).<br>
>> ><br>
>> > 5) Finding or porting a different Hash implementation in C#:<br>
>> >    + Low, constant memory usage.<br>
>> >    + No impact on the large object heap.<br>
>> >    + No limit of data length by the amount of memory.<br>
>> >    + Optimal CPU usage when the hash is only fetched once.<br>
>> >    + Optimal CPU usage when the hash is incrementally fetched several times.<br>
>> ><br>
>> > I've a local prototype implemented for 2), but I'm not sure whether that's<br>
>> > the best way to go...<br>
>><br>
>> Good analysis!<br>
>><br>
>> My preference would be for (4), raising an exception if .update() is called<br>
>> after .digest(), or .copy() is called at all. As a fallback, an extra<br>
>> parameter to hashlib.new (&c) that triggers (2), for cases where its needed -<br>
>> I can't say for sure, but I would think calling .update() after .digest()<br>
>> would be rare, and so would .copy() (damn you Google for shutting down code<br>
>> search). At least then the common case is fast and edge cases are (usually)<br>
>> possible.<br>
><br>
> Do you think asking on some cPython lists could give usable feedback how<br>
> common it is to call copy() or to continue feeding data after calling<br>
> digest()?<br>
><br>
>> > Maybe we should google for purely managed implementations of the hash codes<br>
>> > with a sensible license...<br>
>><br>
>> There seems to be for MD5 and SHA1 but not SHA2 or RIPEMD160. They could be<br>
>> ported from the public domain Crypto++ library, but that seems like a lot of<br>
>> work for an edge case.<br>
><br>
> Yes, that seems to be a lot of work.<br>
><br>
> On the other hand, it's the 100% solution. :-)<br>
><br>
> Best regards<br>
><br>
> Markus Schaber<br>
><br>
> CODESYS® a trademark of 3S-Smart Software Solutions GmbH<br>
><br>
> Inspiring Automation Solutions<br>
><br>
> 3S-Smart Software Solutions GmbH<br>
> Dipl.-Inf. Markus Schaber | Product Development Core Technology<br>
> Memminger Str. 151 | 87439 Kempten | Germany<br>
> Tel. +49-831-54031-979 | Fax +49-831-54031-50<br>
><br>
> E-Mail: <a href="mailto:m.schaber@codesys.com">m.schaber@codesys.com</a> | Web: <a href="http://www.codesys.com" target="_blank">http://www.codesys.com</a> | CODESYS store: <a href="http://store.codesys.com" target="_blank">http://store.codesys.com</a><br>

> CODESYS forum: <a href="http://forum.codesys.com" target="_blank">http://forum.codesys.com</a><br>
><br>
> Managing Directors: Dipl.Inf. Dieter Hess, Dipl.Inf. Manfred Werner | Trade register: Kempten HRB 6186 | Tax ID No.: DE 167014915<br>
><br>
> _______________________________________________<br>
> Ironpython-users mailing list<br>
> <a href="mailto:Ironpython-users@python.org">Ironpython-users@python.org</a><br>
> <a href="https://mail.python.org/mailman/listinfo/ironpython-users" target="_blank">https://mail.python.org/mailman/listinfo/ironpython-users</a><br>
_______________________________________________<br>
Ironpython-users mailing list<br>
<a href="mailto:Ironpython-users@python.org">Ironpython-users@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/ironpython-users" target="_blank">https://mail.python.org/mailman/listinfo/ironpython-users</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Website: <a href="http://earl-of-code.com" target="_blank">http://earl-of-code.com</a>
</div>