On Mon, 14 Dec 2009 03:14:11 +0000, MRAB wrote: >>> You originally stated that you want to "scramble" the bytes -- if >>> you mean to implement some sort of encryption algorithm you should know >>> that most of them work in blocks as the "key" is longer than one byte. >> >> Block ciphers work in blocks. Stream ciphers work on bytes, regardless of >> the length of the key. >> > It's still more efficient to read in blocks, even if you're going to > process the bytes one at a time.
That's fine for a file. If you're reading from a pipe, socket, etc, you typically want to take what you can get when you can get it (although this is easier said than done in Python), rather than waiting for a complete "block". This is often a primary reason for choosing a stream cipher over a block cipher, as it eliminates the need to add and remove padding for intermittent data flows. -- http://mail.python.org/mailman/listinfo/python-list