Background
I am writing an algorithm of encryption, which will probably recieve a huge-size string as an argument. I need to make a block cipher.
Question Actual
To avoid copying the string or create similar object that takes a lot of memory, I want to read the string in a byte manner (each time, read one byte, or one bit), and encrypt the block of data. How can I do that with minimal usage of memory ?
Approach Tried
I have try memoryview
but it only allows bytes
, not str
.
str::encode
looks like it will create a new copy of string in bytes
.
The mmap
seems to be useful, but I do not sure whether it will create new object, or how can I iterate that result.