<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Yea I wasn't a huge fan of the name, I stole it from iterkeys() and I couldn't think of anything better :[</div><br><div><div>On Sep 14, 2013, at 3:27 PM, Alex Gaynor <<a href="mailto:alex.gaynor@gmail.com">alex.gaynor@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">So I've thoguht about this some, I think the idea of using iterables in the API makes a ton of sense, but somehow the `x` and `iter_x` names don't sit right with me, does anyone have any better suggestions?<div>
<br></div><div>Alex</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Sep 11, 2013 at 7:19 PM, Donald Stufft <span dir="ltr"><<a href="mailto:donald@stufft.io" target="_blank">donald@stufft.io</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">So one thing that's really handy to do with encryption is to be able to (de|en)crypt things without needing to load the entire thing into memory. Currently we support this in the encrypt API by doing:<br>
<br>
cipher = BlockCipher()<br>
<br>
enciphered = cipher.encrypt(block1)<br>
enciphered += cipher.encrypt(block2)<br>
enciphered += cipher.encrypt(block3)<br>
enciphered += cipher.finalize()<br>
<br>
We needed to do this because we need to be able to call finalize() before the encryption is "done".<br>
<br>
When I was messing with padding I ended up with an API that (for padding) got around the need for an explicit finalize step but instead it required passing the entire data stream into the function. However it supports generators/iterators so you can still efficiently process large datasets.<br>
<br>
This api looks something like<br>
<br>
padder = Padding()<br>
<br>
padded1 = "".join(padder.pad("1234"))<br>
padded2 = "".join(padder.pad(c for c in "1234"))<br>
<br>
However the downside of this API is that You need to call "".join() to get actual strings or you need to do some ugly hacks inside of the pad() function so it returns a string if given a string and returns a generator if given a generator.<br>
<br>
A third option is similar to dictionaries on Python 2.x where you have something like iterpad() and pad(). This could work for encryption as well so we'd have iter_encrypt(), iter_decrypt(), encrypt() and decrypt().<br>
<br>
So I guess the question is how do we want to handle these streaming sorts of APIs?<br>
<br>
1) Thing.action() + Thing.finalize()<br>
2a) "".join(Thing.action(iterator))<br>
2b) Thing.action(terator OR string) - Magic return types<br>
3) Thing.action and Thing.iter_action<br>
4) ????<br>
<br>
-----------------<br>
Donald Stufft<br>
PGP: 0x6E3CBCE93372DCFA // 7C6B 7C5D 5E2B 6356 A926 F04F 6E3C BCE9 3372 DCFA<br>
<br>
<br>_______________________________________________<br>
Cryptography-dev mailing list<br>
<a href="mailto:Cryptography-dev@python.org">Cryptography-dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/cryptography-dev" target="_blank">https://mail.python.org/mailman/listinfo/cryptography-dev</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">"I disapprove of what you say, but I will defend to the death your right to say it." -- Evelyn Beatrice Hall (summarizing Voltaire)<br>
"The people's good is the highest law." -- Cicero<br><div>GPG Key fingerprint: 125F 5C67 DFE9 4084</div></div>
</div>
_______________________________________________<br>Cryptography-dev mailing list<br><a href="mailto:Cryptography-dev@python.org">Cryptography-dev@python.org</a><br>https://mail.python.org/mailman/listinfo/cryptography-dev<br></blockquote></div><br><div>
<br>-----------------<br>Donald Stufft<br>PGP: 0x6E3CBCE93372DCFA // 7C6B 7C5D 5E2B 6356 A926 F04F 6E3C BCE9 3372 DCFA
</div>
<br></body></html>