Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #106939 > unrolled thread
| Started by | durgadevi1 <srirajarajeswaridevikrupa@gmail.com> |
|---|---|
| First post | 2016-04-13 06:18 -0700 |
| Last post | 2016-04-15 04:46 -0700 |
| Articles | 18 — 10 participants |
Back to article view | Back to comp.lang.python
How to XOR a byte output? durgadevi1 <srirajarajeswaridevikrupa@gmail.com> - 2016-04-13 06:18 -0700
Re: How to XOR a byte output? Chris Angelico <rosuav@gmail.com> - 2016-04-13 23:29 +1000
Re: How to XOR a byte output? durgadevi1 <srirajarajeswaridevikrupa@gmail.com> - 2016-04-13 06:51 -0700
Re: How to XOR a byte output? Chris Angelico <rosuav@gmail.com> - 2016-04-14 00:31 +1000
Re: How to XOR a byte output? Stephen Hansen <me+python@ixokai.io> - 2016-04-13 08:33 -0700
Re: How to XOR a byte output? Marko Rauhamaa <marko@pacujo.net> - 2016-04-13 17:27 +0300
Re: How to XOR a byte output? Ian Kelly <ian.g.kelly@gmail.com> - 2016-04-13 09:30 -0600
Re: How to XOR a byte output? durgadevi1 <srirajarajeswaridevikrupa@gmail.com> - 2016-04-14 01:49 -0700
Re: How to XOR a byte output? Peter Otten <__peter__@web.de> - 2016-04-14 11:16 +0200
Re: How to XOR a byte output? Marko Rauhamaa <marko@pacujo.net> - 2016-04-14 12:18 +0300
Re: How to XOR a byte output? Chris Juried <cjuried@yahoo.com> - 2016-04-14 23:05 +0000
Re: How to XOR a byte output? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-04-15 08:06 -0400
Re: How to XOR a byte output? alister <alister.ware@ntlworld.com> - 2016-04-13 16:15 +0000
[OT] A doubt about a doubt, was Re: How to XOR a byte output? Peter Otten <__peter__@web.de> - 2016-04-13 18:59 +0200
Re: [OT] A doubt about a doubt, was Re: How to XOR a byte output? Rustom Mody <rustompmody@gmail.com> - 2016-04-13 18:54 -0700
Re: [OT] A doubt about a doubt Peter Otten <__peter__@web.de> - 2016-04-14 14:26 +0200
Re: How to XOR a byte output? durgadevi1 <srirajarajeswaridevikrupa@gmail.com> - 2016-04-14 01:32 -0700
Re: How to XOR a byte output? durgadevi1 <srirajarajeswaridevikrupa@gmail.com> - 2016-04-15 04:46 -0700
| From | durgadevi1 <srirajarajeswaridevikrupa@gmail.com> |
|---|---|
| Date | 2016-04-13 06:18 -0700 |
| Subject | How to XOR a byte output? |
| Message-ID | <387506b1-b645-4907-a45c-81a8c3043099@googlegroups.com> |
Hi all,
I have a doubt regarding a problem.
First, I am required to read a given file.
The output from the file is given below:
b'$//W?\xc0\x829\xa2\xb9\x13\x8c\xd5{\'
I used the type() to identify the class and its a byte class.
I saw many \x and thought it might be hex.
So, I used binascii.hexlify() and got the following output:
b'242f2f573fc08239a2b9138cd57b'
Now, this output is being encrypted and I need to perform an XOR operation on it in order to retrieve a secret message.
But, I'm not sure how to code the XOR operation. How do I code that?
Thank you.
PS: I'm not sure if I have done any mistake along the way. That's why I have mentioned all the steps that I've done. Let me know if I have done any step wrongly. :)
[toc] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2016-04-13 23:29 +1000 |
| Message-ID | <mailman.71.1460554158.15650.python-list@python.org> |
| In reply to | #106939 |
On Wed, Apr 13, 2016 at 11:18 PM, durgadevi1
<srirajarajeswaridevikrupa@gmail.com> wrote:
>
> The output from the file is given below:
>
> b'$//W?\xc0\x829\xa2\xb9\x13\x8c\xd5{\'
>
>
> I used the type() to identify the class and its a byte class.
>
> I saw many \x and thought it might be hex.
>
>
> So, I used binascii.hexlify() and got the following output:
> b'242f2f573fc08239a2b9138cd57b'
>
> Now, this output is being encrypted and I need to perform an XOR operation on it in order to retrieve a secret message.
>
> But, I'm not sure how to code the XOR operation. How do I code that?
>
What you have is a series of bytes. They don't have any obvious
meaning right there, so you're going to have to figure out what to XOR
it with.
Let's just guess that you want to xor with the byte value 0xAA. We can
do that fairly simply, using integer operations.
>>> data = b'$//W?\xc0\x829\xa2\xb9\x13\x8c\xd5{\\'
>>> bytes(b ^ 0xAA for b in data)
b'\x8e\x85\x85\xfd\x95j(\x93\x08\x13\xb9&\x7f\xd1\xf6'
Well, that doesn't look much more intelligible. We can try a few other
byte values pretty easily:
>>> bytes(b ^ 0x17 for b in data)
b'388@(\xd7\x95.\xb5\xae\x04\x9b\xc2lK'
>>> bytes(b ^ 0x9D for b in data)
b'\xb9\xb2\xb2\xca\xa2]\x1f\xa4?$\x8e\x11H\xe6\xc1'
>>> bytes(b ^ 0xE2 for b in data)
b'\xc6\xcd\xcd\xb5\xdd"`\xdb@[\xf1n7\x99\xbe'
but it still doesn't look very promising. You're going to need to know
the key - the byte value, or sequence of byte values, to XOR with.
ChrisA
[toc] | [prev] | [next] | [standalone]
| From | durgadevi1 <srirajarajeswaridevikrupa@gmail.com> |
|---|---|
| Date | 2016-04-13 06:51 -0700 |
| Message-ID | <b558f9b2-f961-4bf8-b23a-f054b996c09c@googlegroups.com> |
| In reply to | #106940 |
On Wednesday, April 13, 2016 at 9:29:45 PM UTC+8, Chris Angelico wrote:
> On Wed, Apr 13, 2016 at 11:18 PM, durgadevi1
> <srirajarajeswaridevikrupa@gmail.com> wrote:
> >
> > The output from the file is given below:
> >
> > b'$//W?\xc0\x829\xa2\xb9\x13\x8c\xd5{\'
> >
> >
> > I used the type() to identify the class and its a byte class.
> >
> > I saw many \x and thought it might be hex.
> >
> >
> > So, I used binascii.hexlify() and got the following output:
> > b'242f2f573fc08239a2b9138cd57b'
> >
> > Now, this output is being encrypted and I need to perform an XOR operation on it in order to retrieve a secret message.
> >
> > But, I'm not sure how to code the XOR operation. How do I code that?
> >
>
> What you have is a series of bytes. They don't have any obvious
> meaning right there, so you're going to have to figure out what to XOR
> it with.
>
> Let's just guess that you want to xor with the byte value 0xAA. We can
> do that fairly simply, using integer operations.
>
> >>> data = b'$//W?\xc0\x829\xa2\xb9\x13\x8c\xd5{\\'
> >>> bytes(b ^ 0xAA for b in data)
> b'\x8e\x85\x85\xfd\x95j(\x93\x08\x13\xb9&\x7f\xd1\xf6'
>
> Well, that doesn't look much more intelligible. We can try a few other
> byte values pretty easily:
>
> >>> bytes(b ^ 0x17 for b in data)
> b'388@(\xd7\x95.\xb5\xae\x04\x9b\xc2lK'
> >>> bytes(b ^ 0x9D for b in data)
> b'\xb9\xb2\xb2\xca\xa2]\x1f\xa4?$\x8e\x11H\xe6\xc1'
> >>> bytes(b ^ 0xE2 for b in data)
> b'\xc6\xcd\xcd\xb5\xdd"`\xdb@[\xf1n7\x99\xbe'
>
> but it still doesn't look very promising. You're going to need to know
> the key - the byte value, or sequence of byte values, to XOR with.
>
> ChrisA
Ok thank you ChrisA. :)
I would like to check with you whether using binascii.hexlify() to convert the series of bytes into alphabets and integers is correct.
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2016-04-14 00:31 +1000 |
| Message-ID | <mailman.75.1460557895.15650.python-list@python.org> |
| In reply to | #106942 |
On Wed, Apr 13, 2016 at 11:51 PM, durgadevi1 <srirajarajeswaridevikrupa@gmail.com> wrote: > Ok thank you ChrisA. :) > > I would like to check with you whether using binascii.hexlify() to convert the series of bytes into alphabets and integers is correct. It converts the bytes (which are small integers) into the hexadecimal representation of them (which is digits 0-9 and A-F or a-f). It's often the easiest way to see what the byte values *are*, but it doesn't help you much with figuring out what they *mean*. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Stephen Hansen <me+python@ixokai.io> |
|---|---|
| Date | 2016-04-13 08:33 -0700 |
| Message-ID | <mailman.78.1460561634.15650.python-list@python.org> |
| In reply to | #106942 |
On Wed, Apr 13, 2016, at 06:51 AM, durgadevi1 wrote:
> I would like to check with you whether using binascii.hexlify() to
> convert the series of bytes into alphabets and integers is correct.
To be clear, they already are integers.The \x notation is how you
naively represent a byte out of the printable range in ASCII. A byte is
a number from 0 to 255, which can also be thought of as 0x00 to 0xFF..
The 'printable range' is those bytes which represent normal characters
instead of control codes and such.
Computers like showing raw byte data in hex \x (which shouldn't be
confused with binascii.hexify) because then each byte concisely fills up
exactly 2 (well, 4, counting the \x) characters, instead of some bytes
being only one character (1), some being two (10), and some being three
(100).
You can see the integer value, consider:
>>> data = b'$//W?\xc0\x829\xa2\xb9\x13\x8c\xd5{\\'
>>> print data[0]
36
>>> print data[10]
19
>>> list(data)
[36, 47, 47, 87, 63, 192, 130, 57, 162, 185, 19, 140, 213, 123, 92]
binascii is almost certainly not what you want: that converts arbitrary
bytes into an ASCII encoded string, at which point its no longer bytes
(and before you did something to it besides displaying it, you'd want to
decode it back to bytes again, probably).
--Stephen
m e @ i x o k a i . i o
[toc] | [prev] | [next] | [standalone]
| From | Marko Rauhamaa <marko@pacujo.net> |
|---|---|
| Date | 2016-04-13 17:27 +0300 |
| Message-ID | <874mb5twha.fsf@elektro.pacujo.net> |
| In reply to | #106940 |
Chris Angelico <rosuav@gmail.com>:
> Let's just guess that you want to xor with the byte value 0xAA. We can
> do that fairly simply, using integer operations.
>
>>>> data = b'$//W?\xc0\x829\xa2\xb9\x13\x8c\xd5{\\'
>>>> bytes(b ^ 0xAA for b in data)
> b'\x8e\x85\x85\xfd\x95j(\x93\x08\x13\xb9&\x7f\xd1\xf6'
>
> Well, that doesn't look much more intelligible.
This looks clearer:
>>> code = b'a0\xed\xf0Z\x15]g^\xce3x'
>>> key = b')U\x81\x9c55*\x08,\xa2WY'
>>> bytes(c ^ k for c, k in zip(code, key)).decode()
'Hello world!'
Marko
[toc] | [prev] | [next] | [standalone]
| From | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| Date | 2016-04-13 09:30 -0600 |
| Message-ID | <mailman.77.1460561490.15650.python-list@python.org> |
| In reply to | #106946 |
On Wed, Apr 13, 2016 at 8:27 AM, Marko Rauhamaa <marko@pacujo.net> wrote:
> Chris Angelico <rosuav@gmail.com>:
>
>> Let's just guess that you want to xor with the byte value 0xAA. We can
>> do that fairly simply, using integer operations.
>>
>>>>> data = b'$//W?\xc0\x829\xa2\xb9\x13\x8c\xd5{\\'
>>>>> bytes(b ^ 0xAA for b in data)
>> b'\x8e\x85\x85\xfd\x95j(\x93\x08\x13\xb9&\x7f\xd1\xf6'
>>
>> Well, that doesn't look much more intelligible.
>
> This looks clearer:
>
> >>> code = b'a0\xed\xf0Z\x15]g^\xce3x'
> >>> key = b')U\x81\x9c55*\x08,\xa2WY'
> >>> bytes(c ^ k for c, k in zip(code, key)).decode()
> 'Hello world!'
But that's not the code from the OP's post. The solution is obviously this:
>>> code = b'$//W?\xc0\x829\xa2\xb9\x13\x8c\xd5{'
>>> key = b'm\x0fC8I\xa5\xa2i\xdb\xcd{\xe3\xbbZ'
>>> bytes(c ^ k for c, k in zip(code, key)).decode()
'I love Python!'
[toc] | [prev] | [next] | [standalone]
| From | durgadevi1 <srirajarajeswaridevikrupa@gmail.com> |
|---|---|
| Date | 2016-04-14 01:49 -0700 |
| Message-ID | <2566ab7f-12bd-4f3b-92b2-45104b8b7dd8@googlegroups.com> |
| In reply to | #106946 |
> > This looks clearer: > > >>> code = b'a0\xed\xf0Z\x15]g^\xce3x' > >>> key = b')U\x81\x9c55*\x08,\xa2WY' > >>> bytes(c ^ k for c, k in zip(code, key)).decode() > 'Hello world!' > > > Marko Hi, I have gotten another error message when working with the bytes(c ^ k for c, k in zip(code, key)).decode(). Here is the error. print(bytes(c ^ k for c, k in zip(CODE, key)).decode()) UnicodeDecodeError: 'utf-8' codec can't decode byte 0x85 in position 0: invalid start byte What I did is XOR the CODE with a certain value before using the bytes(c ^ k for c, k in zip(CODE, key)).decode() code. However, I get no errors when using values 0 to 127 to XOR with CODE. But I get errors when using values (128 to 255). May I know how I can modify the program code so that i can XOR with values (128 to 255)?
[toc] | [prev] | [next] | [standalone]
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Date | 2016-04-14 11:16 +0200 |
| Message-ID | <mailman.99.1460625428.15650.python-list@python.org> |
| In reply to | #106985 |
durgadevi1 wrote:
>
>>
>> This looks clearer:
>>
>> >>> code = b'a0\xed\xf0Z\x15]g^\xce3x'
>> >>> key = b')U\x81\x9c55*\x08,\xa2WY'
>> >>> bytes(c ^ k for c, k in zip(code, key)).decode()
>> 'Hello world!'
>>
>>
>> Marko
>
> Hi, I have gotten another error message when working with the bytes(c ^ k
> for c, k in zip(code, key)).decode().
>
> Here is the error.
> print(bytes(c ^ k for c, k in zip(CODE, key)).decode())
> UnicodeDecodeError: 'utf-8' codec can't decode byte 0x85 in position 0:
> invalid start byte
>
> What I did is XOR the CODE with a certain value before using the
>
> bytes(c ^ k for c, k in zip(CODE, key)).decode() code.
>
> However, I get no errors when using values 0 to 127 to XOR with CODE. But
> I get errors when using values (128 to 255). May I know how I can modify
> the program code so that i can XOR with values (128 to 255)?
By default bytes.decode() interprets the sequence of bytes as UTF-8. This
will fail if for example there is a lone 0x85 because no encoded character
in UTF-8 starts with that byte:
>>> code = b'a0\xed\xf0Z\x15]g^\xce3x'
>>> key = b'\xe4U\x81\x9c55*\x08,\xa2WY'
>>> decrypted = bytes(c^k for c, k in zip(code, key))
>>> decrypted
b'\x85ello world!'
>>> decrypted.decode()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x85 in position 0:
invalid start byte
If you explicitly choose an encoding that maps every single byte to exactly
one character (e. g. ISO-8859-15),
>>> decrypted.decode("iso-8859-15")
'\x85ello world!'
the conversion cannot fail -- but the result may still not make sense.
[toc] | [prev] | [next] | [standalone]
| From | Marko Rauhamaa <marko@pacujo.net> |
|---|---|
| Date | 2016-04-14 12:18 +0300 |
| Message-ID | <87potssg4n.fsf@elektro.pacujo.net> |
| In reply to | #106985 |
durgadevi1 <srirajarajeswaridevikrupa@gmail.com>: >> >>> bytes(c ^ k for c, k in zip(code, key)).decode() > > [...] > UnicodeDecodeError: 'utf-8' codec can't decode byte 0x85 in position 0: > invalid start byte > > [...] > > However, I get no errors when using values 0 to 127 to XOR with CODE. > But I get errors when using values (128 to 255). May I know how I can > modify the program code so that i can XOR with values (128 to 255)? Leave out .decode() at the end. Marko
[toc] | [prev] | [next] | [standalone]
| From | Chris Juried <cjuried@yahoo.com> |
|---|---|
| Date | 2016-04-14 23:05 +0000 |
| Message-ID | <mailman.120.1460678159.15650.python-list@python.org> |
| In reply to | #106987 |
Hello list,
I am new to the list and was wondering if anyone is using Python for MCU programing? In particular the AVR and ARM based controllers. Is Python a plausible language for MCU programming or is C/C++ or Assembly the only way to go? Thanks in advance for your insight.
Sincerely,
Chris
Audio Engineering Society (AES) Member
InfoComm-Recognized AV Technologist
http://www.JuriedEngineering.com (Juried Engineering, LLC.)
http://www.TubeEquipment.com (Tube Equipment Corporation)
http://www.HistoryOfRecording.com (History of Recording)
This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information. If you are not the intended recipient of this e-mail, you are hereby notified that any distribution or copying of this email, and any attachments thereto, is strictly prohibited. If you have received this email in error, please immediately notify me at (754) 300-9972 and permanently delete the original and any copy of any e-mail and any printout thereof.
[toc] | [prev] | [next] | [standalone]
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| Date | 2016-04-15 08:06 -0400 |
| Message-ID | <mailman.16.1460722005.6324.python-list@python.org> |
| In reply to | #106987 |
On Thu, 14 Apr 2016 23:05:03 +0000 (UTC), Chris Juried via Python-list
<python-list@python.org> declaimed the following:
>Hello list,
>I am new to the list and was wondering if anyone is using Python for MCU programing? In particular the
First matter: You should have created a new thread, rather than
piggy-backing on an existing thread. Your question has nothing to do with
the thread subject (XOR a byte).
>AVR and ARM based controllers. Is Python a plausible language for MCU programming or is C/C++ or Assembly the only way to go? Thanks in advance for your insight.
Most implementations of Python are of a byte-code interpreted language.
It does not produce native executable binaries. That means that to use it
on those microcontrollers you would have to first port the interpreter to
the controller. That alone may consume the entire FLASH memory space --
even before you add library modules to access the hardware (Python doesn't
"do" hardware level access -- there is no "pointer to memory" you can set
to write to pins). The core of the interpreter, for 32-bit Windows, is
nearly 300KB -- more than the 256KB available on a TIVA TM4C123 Launchpad.
You'd then need to implement a file system so the interpreter could locate
and load library modules used by your program (not to mention the program
itself).
At that point you've created the Python equivalent of the old Parallax
BASIC Stamp (in which the MCU FLASH is loaded with the interpreter of a
very limited BASIC, and off-chip memory is used to hold the pre-compiled
byte code of your program). Or the newer Parallax Propeller chip -- in
which the boot sequence loads a very short interpreter for the SPIN
language into the processor core from off-chip memory before it starts to
interpret byte-codes. Though unlike the BASIC Stamp, the Propeller also
gives you access to assembly (assembly programs get loaded into the core
memory instead of the interpreter -- so run much faster).
You can run it (Python) on things like the BeagleBone Black and
Raspberry PI -- but those cards are using application SoC processors
running a form of Linux; they aren't running bare-bones direct hardware
access.
For microcontrollers, you typically need to have a compiled language
that produces a memory image that can execute in place. It may not be C/C++
-- I believe a few efforts have been made for a no-run-time GNAT Ada to run
on some ARM devices.
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
[toc] | [prev] | [next] | [standalone]
| From | alister <alister.ware@ntlworld.com> |
|---|---|
| Date | 2016-04-13 16:15 +0000 |
| Message-ID | <AguPy.838728$hz.468617@fx42.am4> |
| In reply to | #106939 |
On Wed, 13 Apr 2016 06:18:22 -0700, durgadevi1 wrote:
> Hi all,
>
> I have a doubt regarding a problem.
>
No, you have a question doubt means you don't believe something
(sorry I know this is not an English language lesson)
> First, I am required to read a given file.
>
>
> The output from the file is given below:
>
> b'$//W?\xc0\x829\xa2\xb9\x13\x8c\xd5{\'
>
>
> I used the type() to identify the class and its a byte class.
>
correct it is a string o bytes & bytes that do not have a dispalyable
ASCI character are shown using the \x<hex> format
> I saw many \x and thought it might be hex.
>
>
> So, I used binascii.hexlify() and got the following output:
> b'242f2f573fc08239a2b9138cd57b'
>
> Now, this output is being encrypted and I need to perform an XOR
> operation on it in order to retrieve a secret message.
>
No you ned to perform the Xor operation on the original bytes hexifying
the string will not help you (it will actual make the situation worse)
> But, I'm not sure how to code the XOR operation. How do I code that?
without completing your homework for you, the principle is
step through each byte in turn
perform the XOR function
add the result to a new byte string.
if you are using the correct xor value hopefully you will get a readable
output.
>
> Thank you.
>
> PS: I'm not sure if I have done any mistake along the way. That's why I
> have mentioned all the steps that I've done. Let me know if I have done
> any step wrongly. :)
indeed this has been better written than most homework assistance
requests posted here that simply want a solution, but mentioning it is
homework would be better still.
--
Don't let your status become too quo!
[toc] | [prev] | [next] | [standalone]
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Date | 2016-04-13 18:59 +0200 |
| Subject | [OT] A doubt about a doubt, was Re: How to XOR a byte output? |
| Message-ID | <mailman.84.1460566792.15650.python-list@python.org> |
| In reply to | #106956 |
alister wrote: > On Wed, 13 Apr 2016 06:18:22 -0700, durgadevi1 wrote: > >> I have a doubt regarding a problem. >> > No, you have a question doubt means you don't believe something > (sorry I know this is not an English language lesson) "doubt" is commonly used that way in Indian English, see http://english.stackexchange.com/questions/2429/can-doubt-sometimes-mean-question
[toc] | [prev] | [next] | [standalone]
| From | Rustom Mody <rustompmody@gmail.com> |
|---|---|
| Date | 2016-04-13 18:54 -0700 |
| Subject | Re: [OT] A doubt about a doubt, was Re: How to XOR a byte output? |
| Message-ID | <0c3cfac3-2e66-4341-ab51-1517cb13f1a4@googlegroups.com> |
| In reply to | #106960 |
On Wednesday, April 13, 2016 at 10:30:07 PM UTC+5:30, Peter Otten wrote: > alister wrote: > > > On Wed, 13 Apr 2016 06:18:22 -0700, durgadevi1 wrote: > > > >> I have a doubt regarding a problem. > >> > > No, you have a question doubt means you don't believe something > > (sorry I know this is not an English language lesson) > > "doubt" is commonly used that way in Indian English, see > > http://english.stackexchange.com/questions/2429/can-doubt-sometimes-mean-question I have a doubt: Is it incorrect to correct someone when they are incorrect? [Sprinkle a "politically" on the above to taste <Wink>]
[toc] | [prev] | [next] | [standalone]
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Date | 2016-04-14 14:26 +0200 |
| Subject | Re: [OT] A doubt about a doubt |
| Message-ID | <mailman.104.1460636787.15650.python-list@python.org> |
| In reply to | #106968 |
Rustom Mody wrote: > I have a doubt: > Is it incorrect to correct someone when they are incorrect? No doubt about it. Everyone's a winner... > [Sprinkle a "politically" on the above to taste <Wink>] Ah, contradictio in adiecto. That shifts it to definitely maybe.
[toc] | [prev] | [next] | [standalone]
| From | durgadevi1 <srirajarajeswaridevikrupa@gmail.com> |
|---|---|
| Date | 2016-04-14 01:32 -0700 |
| Message-ID | <625b8dac-16df-4075-ae4e-4344c1c5a4d3@googlegroups.com> |
| In reply to | #106939 |
On Wednesday, April 13, 2016 at 9:18:37 PM UTC+8, durgadevi1 wrote:
> Hi all,
>
> I have a doubt regarding a problem.
>
> First, I am required to read a given file.
>
>
> The output from the file is given below:
>
> b'$//W?\xc0\x829\xa2\xb9\x13\x8c\xd5{\'
>
>
> I used the type() to identify the class and its a byte class.
>
> I saw many \x and thought it might be hex.
>
>
> So, I used binascii.hexlify() and got the following output:
> b'242f2f573fc08239a2b9138cd57b'
>
> Now, this output is being encrypted and I need to perform an XOR operation on it in order to retrieve a secret message.
>
> But, I'm not sure how to code the XOR operation. How do I code that?
>
> Thank you.
>
> PS: I'm not sure if I have done any mistake along the way. That's why I have mentioned all the steps that I've done. Let me know if I have done any step wrongly. :)
Ok thank you very much for your replies :)
[toc] | [prev] | [next] | [standalone]
| From | durgadevi1 <srirajarajeswaridevikrupa@gmail.com> |
|---|---|
| Date | 2016-04-15 04:46 -0700 |
| Message-ID | <9013f588-383f-4c74-a354-9cba77a2ae70@googlegroups.com> |
| In reply to | #106939 |
On Wednesday, April 13, 2016 at 9:18:37 PM UTC+8, durgadevi1 wrote:
> Hi all,
>
> I have a doubt regarding a problem.
>
> First, I am required to read a given file.
>
>
> The output from the file is given below:
>
> b'$//W?\xc0\x829\xa2\xb9\x13\x8c\xd5{\'
>
>
> I used the type() to identify the class and its a byte class.
>
> I saw many \x and thought it might be hex.
>
>
> So, I used binascii.hexlify() and got the following output:
> b'242f2f573fc08239a2b9138cd57b'
>
> Now, this output is being encrypted and I need to perform an XOR operation on it in order to retrieve a secret message.
>
> But, I'm not sure how to code the XOR operation. How do I code that?
>
> Thank you.
>
> PS: I'm not sure if I have done any mistake along the way. That's why I have mentioned all the steps that I've done. Let me know if I have done any step wrongly. :)
Ok thanks guys :)
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web