[Tutor] string to binary and back... Python 3

Dave Angel d at davea.name
Thu Jul 19 21:53:24 CEST 2012


On 07/19/2012 03:19 PM, Jordan wrote:
> <SNIP>
>
> OK. I am using one time pads to XOR data, but the one time pads (keys)
> are very large numbers, converting them to binary increases their size
> exponentially, which allows me to get more XORing done out of a single

You want to explain this impossibility of increasing size
exponentially?  If you're wanting to waste memory, there are better
ways.  But it's only 8 times as big to save a string of 1's and zeros as
to save the large-int they represent.  And multiplying by 8 isn't an
exponential function.

> key. I am XORing both files and strings so I need to have code that can
> do both even if that means two branches of code via an if/else perhaps
> with an isinstance(data, str).
> I do not need to actually see the binary form.
>

Then don't use the binary form.  It doesn't make the computation any
more "powerful" and it'll certainly slow it down.

Are you trying to match some other program's algorithm, and thus have
strange constraints on your data?  Or are you simply trying to make a
secure way to encrypt binary files, using one-time pads?

A one-time pad is the same size as the message, so you simply need to
convert the message into a large-int, and xor them.


-- 

DaveA



More information about the Tutor mailing list