[Tutor] string to binary and back... Python 3
Jordan
wolfrage8765 at gmail.com
Thu Jul 19 23:32:37 CEST 2012
On 07/19/2012 10:48 PM, Prasad, Ramit 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.
>>>
>> Yes if you wish to dissect my words the wrong word was chosen...
>>>> 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.
>> The title of the question is string to binary and back.
>>> 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?
>> I already answered this question...
> Yes, you stated that it had to work on string and files, but are the
> files binary? DaveA and I are asking the questions because given
> what you are asking it just seems like you are not using the Right
> approach. I can touch my nose by touching my nose with my hand,
> or asking the person next to me to pick up my hand and use it to
> touch my nose. Both work, one is just faster and easier to
> understand.
I am not sure how to answer that question because all files are binary,
but the files that I will parse have an encoding that allows them to be
read in a non-binary output. But my program will not use the in a
non-binary way, that is why I plan to open them with the 'b' mode to
open them as binary with no encoding assumed by python. I just not have
tested this new technique that you gave me on a binary file yet as I was
still implementing it for strings.
I may not be using the right appraoch that is why I am asking. I also
understand why the questions are needed, so you can understand my
intent, so that you can better help me. But since DaveA and I had a
misunderstanding over the missing indentation, for which I apologized
and explained that my email editor is stripping the spaces, he seems to
be badgering me.
"You want to explain this impossibility of increasing size
exponentially? If you're wanting to waste memory, there are better
ways."
Now I would like to make it clear I very much so appreciate the help! So
again, Thank you.
>
>>> 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.
> Ramit
> This email is confidential and subject to important disclaimers and
> conditions including on offers for the purchase or sale of
> securities, accuracy and completeness of information, viruses,
> confidentiality, legal privilege, and legal entity disclaimers,
> available at http://www.jpmorgan.com/pages/disclosures/email.
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list