Re: Converting hex data to image

2021-01-31 Thread Ali Sajadian
dimplem...@gmail.com در تاریخ سه‌شنبه ۱۲ مارس ۲۰۱۹ ساعت ۱۳:۰۱:۴۵ (UTC+3:30) نوشت: > On Tuesday, March 12, 2019 at 2:53:49 PM UTC+5:30, Peter Otten wrote: > > dimplem...@gmail.com wrote: > > > > >> Save the image to a file (in binary mode!) and then try to open it with > > >> an image viewer. T

Re: numpy array - convert hex to int

2019-09-10 Thread Piet van Oostrum
Sharan Basappa writes: > On Sunday, 8 September 2019 11:16:52 UTC-4, Luciano Ramalho wrote: >> >>> int('C0FFEE', 16) >> 12648430 >> >> There you go! >> >> On Sun, Sep 8, 2019 at 12:02 PM Sharan Basappa >> wrote: >> >

Re: numpy array - convert hex to int

2019-09-09 Thread Sharan Basappa
On Sunday, 8 September 2019 11:16:52 UTC-4, Luciano Ramalho wrote: > >>> int('C0FFEE', 16) > 12648430 > > There you go! > > On Sun, Sep 8, 2019 at 12:02 PM Sharan Basappa > wrote: > > > > I have a numpy array that has data in the form o

Re: Color representation as rgb, int and hex

2019-09-09 Thread Eko palypse
> No, constructing a bytes literal from hex digits implies that they > follow the sequence in the string of digits. It's nothing to do with > the endinanness of integers. > ChrisA > Why should it imply that? You're asking it to create some bytes > from a string of

Re: Color representation as rgb, int and hex

2019-09-09 Thread Gregory Ewing
Eko palypse wrote: I thought a method called fromhex would imply that bytes for an integer should be created Why should it imply that? You're asking it to create some bytes from a string of hex digits -- no mention of integers. The obvious thing to do is to put the bytes in the order

Re: Color representation as rgb, int and hex

2019-09-08 Thread Chris Angelico
bytes for an integer > should be created and as that it would use the proper byte order to create it. > But it seems that it treats the string literally. > Isn't that confusing? > No, constructing a bytes literal from hex digits implies that they follow the sequence in the string of

Re: Color representation as rgb, int and hex

2019-09-08 Thread Eko palypse
> ChrisA You are correct, but, sorry for not being clear what confused me. I assumed it would use the sys.byteorder but I guess this is simply a AssumedError exception. :-) -- https://mail.python.org/mailman/listinfo/python-list

Re: Color representation as rgb, int and hex

2019-09-08 Thread Eko palypse
> You haven't said whether your machine is big-endian or little-endian. Correct, it is little but I'm wondering why this isn't taking into account. I thought a method called fromhex would imply that bytes for an integer should be created and as that it would use the proper byte order to create it.

Re: Color representation as rgb, int and hex

2019-09-08 Thread Chris Angelico
On Mon, Sep 9, 2019 at 6:01 AM Eko palypse wrote: > > I'm confused about the following > > import sys > print(tuple(bytes.fromhex('282C34'))) > print(tuple((0x282C34).to_bytes(3, byteorder=sys.byteorder))) > > which results in > > (40, 44, 52) > (52, 44, 40) > > on my machine. Shouldn't I expect t

Re: Color representation as rgb, int and hex

2019-09-08 Thread MRAB
On 2019-09-08 20:58, Eko palypse wrote: I'm confused about the following import sys print(tuple(bytes.fromhex('282C34'))) print(tuple((0x282C34).to_bytes(3, byteorder=sys.byteorder))) which results in (40, 44, 52) (52, 44, 40) on my machine. Shouldn't I expect the same result? You haven't s

Color representation as rgb, int and hex

2019-09-08 Thread Eko palypse
I'm confused about the following import sys print(tuple(bytes.fromhex('282C34'))) print(tuple((0x282C34).to_bytes(3, byteorder=sys.byteorder))) which results in (40, 44, 52) (52, 44, 40) on my machine. Shouldn't I expect the same result? Thank you Eren -- https://mail.python.org/mailman/list

Re: numpy array - convert hex to int

2019-09-08 Thread Luciano Ramalho
>>> int('C0FFEE', 16) 12648430 There you go! On Sun, Sep 8, 2019 at 12:02 PM Sharan Basappa wrote: > > I have a numpy array that has data in the form of hex. > I would like to convert that into decimal/integer. > Need suggestions please. > -- > https://ma

numpy array - convert hex to int

2019-09-08 Thread Sharan Basappa
I have a numpy array that has data in the form of hex. I would like to convert that into decimal/integer. Need suggestions please. -- https://mail.python.org/mailman/listinfo/python-list

Re: Converting hex data to image

2019-03-12 Thread dimplemathew . 17
On Tuesday, March 12, 2019 at 2:53:49 PM UTC+5:30, Peter Otten wrote: > dimplemathew...@gmail.com wrote: > > >> Save the image to a file (in binary mode!) and then try to open it with > >> an image viewer. The data may be corrupted. > > > > When i tried doing that it says Invalid Image... > > So

Re: Converting hex data to image

2019-03-12 Thread Peter Otten
dimplemathew...@gmail.com wrote: >> Save the image to a file (in binary mode!) and then try to open it with >> an image viewer. The data may be corrupted. > > When i tried doing that it says Invalid Image... So it looks like the problem occurs somewhere before you are decoding the image with th

Re: Converting hex data to image

2019-03-12 Thread dimplemathew . 17
On Tuesday, March 12, 2019 at 2:09:06 PM UTC+5:30, Peter Otten wrote: > dimplemathew...@gmail.com wrote: > > > On Monday, March 11, 2019 at 4:32:48 PM UTC+5:30, Peter Otten wrote: > >> dimplemathew...@gmail.com wrote: > >> > >> > Hi i have a similar challenge where i need to store the thumbnailPh

Re: Converting hex data to image

2019-03-12 Thread Peter Otten
dimplemathew...@gmail.com wrote: > On Monday, March 11, 2019 at 4:32:48 PM UTC+5:30, Peter Otten wrote: >> dimplemathew...@gmail.com wrote: >> >> > Hi i have a similar challenge where i need to store the thumbnailPhoto >> > attribute to my local db and display the image every-time user logs in. >

Re: Converting hex data to image

2019-03-11 Thread dimplemathew . 17
On Monday, March 11, 2019 at 4:32:48 PM UTC+5:30, Peter Otten wrote: > dimplemathew...@gmail.com wrote: > > > Hi i have a similar challenge where i need to store the thumbnailPhoto > > attribute to my local db and display the image every-time user logs in. > > But this solution does work . data lo

Re: Converting hex data to image

2019-03-11 Thread dimplemathew . 17
the user contains the > thumbnail photo in hex representation. E.x.: > > > [('CN=XX,OU=Users,OU=Accounts,DC=test,DC=com', {'msExchBlockedSendersHash': > ['\xce'], 'mailNickname': ['test_user'], 'primaryGroupID': ['51

Re: Converting hex data to image

2019-03-11 Thread Peter Otten
dimplemathew...@gmail.com wrote: > Hi i have a similar challenge where i need to store the thumbnailPhoto > attribute to my local db and display the image every-time user logs in. > But this solution does work . data looks like this: > \xff\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x01\x00`\x00`\x00\x0

Re: Converting hex data to image

2019-03-11 Thread dimplemathew . 17
On Friday, November 15, 2013 at 3:52:58 AM UTC+5:30, Shyam Parimal Katti wrote: > Perfect. Thank you @Ben and @Tim > > > > > On Thu, Nov 14, 2013 at 4:29 PM, Ben Finney wrote: > > > Ben Finney writes: > > > > > > To turn a byte string into a file-like object for use with PIL, extract >

RE: Python regex pattern from array of hex chars

2018-04-13 Thread Joseph L. Casale
-Original Message- From: Python-list On Behalf Of MRAB Sent: Friday, April 13, 2018 12:05 PM To: python-list@python.org Subject: Re: Python regex pattern from array of hex chars > Use re.escape: > > regex = re.compile('[^{}]+'.format(re.escape(''.join

Re: Python regex pattern from array of hex chars

2018-04-13 Thread MRAB
On 2018-04-13 18:28, Joseph L. Casale wrote: I have an array of hex chars which designate required characters. and one happens to be \x5C or "\". What foo is required to build the pattern to exclude all but: regex = re.compile('[^{}]+'.format(''.join(c for c in c

Python regex pattern from array of hex chars

2018-04-13 Thread Joseph L. Casale
I have an array of hex chars which designate required characters. and one happens to be \x5C or "\". What foo is required to build the pattern to exclude all but: regex = re.compile('[^{}]+'.format(''.join(c for c in character_class))) I would use that in a re.sub t

Re: Python - decode('hex')

2017-02-20 Thread Ganesh Pal
7 17:55, Ganesh Pal wrote: >> >> 1. The only difference between both the programs the difference are just >>> the below lines. >>> >>> newdata = '64000101057804'.decode('hex') >>> >>> and >>> >>>

Re: Python - decode('hex')

2017-02-20 Thread Steve D'Aprano
oks like program 1. In an earlier post, you even pointed out that there is just a single, three line difference between the two programs: [quote] 1. The only difference between both the programs the difference are just the below lines. newdata = '64000101057804'.decode('hex&

Re: Python - decode('hex')

2017-02-20 Thread MRAB
On 2017-02-20 19:43, Ganesh Pal wrote: On Feb 21, 2017 12:17 AM, "Rhodri James" wrote: On 20/02/17 17:55, Ganesh Pal wrote: 1. The only difference between both the programs the difference are just the below lines. newdata = '64000101057804'.decode('hex')

Re: Python - decode('hex')

2017-02-20 Thread Ganesh Pal
On Feb 21, 2017 12:17 AM, "Rhodri James" wrote: On 20/02/17 17:55, Ganesh Pal wrote: > 1. The only difference between both the programs the difference are just > the below lines. > > newdata = '64000101057804'.decode('hex') > >

Re: Python - decode('hex')

2017-02-20 Thread MRAB
x27;%08X: %s\n' % (offset, stringdata.encode('hex')) #Replace data at offset with newdata f.seek(offset) f.write(newdata) There's no need to explicitly close the file because when you leave the 'with' statement, it'll close the file for yo

Re: Python - decode('hex')

2017-02-20 Thread Rhodri James
On 20/02/17 17:55, Ganesh Pal wrote: 1. The only difference between both the programs the difference are just the below lines. newdata = '64000101057804'.decode('hex') and newdata = "" newdata = '64000101057804' newdata.decode('hex')

Python - decode('hex')

2017-02-20 Thread Ganesh Pal
replace_hex(fname, offset, newdata): #pdb.set_trace() with open(fname, 'r+b') as f: #Show current contents f.seek(offset) stringdata = f.read(len(newdata)) print 'Current data:' print '%08X: %s\n' % (offset, stringdata.en

Re: Efficient handling of fast, real-time hex data

2016-06-02 Thread alister
On Thu, 02 Jun 2016 05:41:40 -0400, Gene Heskett wrote: > On Thursday 02 June 2016 04:13:51 alister wrote: > >> On Thu, 02 Jun 2016 18:50:34 +1200, Gregory Ewing wrote: >> > jlada...@itu.edu wrote: >> >> One common data transmission error I've seen in other systems is >> >> added/dropped bytes. I

Re: Efficient handling of fast, real-time hex data

2016-06-02 Thread Gene Heskett
On Thursday 02 June 2016 04:13:51 alister wrote: > On Thu, 02 Jun 2016 18:50:34 +1200, Gregory Ewing wrote: > > jlada...@itu.edu wrote: > >> One common data transmission error I've seen in other systems is > >> added/dropped bytes. I may add a CRC-8 error-checking byte in place > >> of the newline

Re: Efficient handling of fast, real-time hex data

2016-06-02 Thread alister
On Thu, 02 Jun 2016 18:50:34 +1200, Gregory Ewing wrote: > jlada...@itu.edu wrote: >> One common data transmission error I've seen in other systems is >> added/dropped bytes. I may add a CRC-8 error-checking byte in place of >> the newline. > > Also maybe add a start byte with a known value at th

Re: Efficient handling of fast, real-time hex data

2016-06-01 Thread Gregory Ewing
jlada...@itu.edu wrote: One common data transmission error I've seen in other systems is added/dropped bytes. I may add a CRC-8 error-checking byte in place of the newline. Also maybe add a start byte with a known value at the beginning of each packet to help resynchronise if you get out of ste

Re: Efficient handling of fast, real-time hex data

2016-06-01 Thread jladasky
On Tuesday, May 31, 2016 at 9:37:18 PM UTC-7, Gregory Ewing wrote: > > So, how can I take the byte sequence <0x01 0x02 0x03 0x04 0x05 0x06 \n> that > > Serial.readline() returns to me, > > Using readline() to read binary data doesn't sound like > a good idea -- what happens if one of the data byte

Re: Efficient handling of fast, real-time hex data

2016-05-31 Thread Gregory Ewing
jlada...@itu.edu wrote: So, how can I take the byte sequence <0x01 0x02 0x03 0x04 0x05 0x06 \n> that Serial.readline() returns to me, Using readline() to read binary data doesn't sound like a good idea -- what happens if one of the data bytes happens to be 0x0a? If you're going binary, it woul

Re: Efficient handling of fast, real-time hex data

2016-05-31 Thread Paul Rubin
jlada...@itu.edu writes: > high rate, about 5,000 16-bit unsigned integers per second > Using PySerial to handle UART over USB. Intel Core i7-4790K CPU @ > 4.00GHz. This really should not be an issue. That's not such a terribly high speed, and there's enough buffering in the kernel that you

Re: Efficient handling of fast, real-time hex data

2016-05-31 Thread jladasky
On Tuesday, May 31, 2016 at 5:36:10 PM UTC-7, Michael Torrie wrote: > > I think you might want to use the struct module. It's designed for this > kind of packing and unpacking: > > https://docs.python.org/3/library/struct.html Hi Michael, Thanks for pointing me at the struct module. There appe

Re: Efficient handling of fast, real-time hex data

2016-05-31 Thread jladasky
On Tuesday, May 31, 2016 at 6:02:07 PM UTC-7, Rob Gaddi wrote: > You'll probably want to process it in blocks. Allocate a 3kB > bytearray, assign into it from the data coming in off Serial (less > the newlines) and when you fill it, call numpy.from_buffer to rip it. Thanks Rob, numpy.frombuffer

Re: Efficient handling of fast, real-time hex data

2016-05-31 Thread Rob Gaddi
jlada...@itu.edu wrote: > Greetings everyone, > > I'm developing small embedded systems. I can't use Python to program them, I > have to program the little CPU's in C. > > I want a peripheral I've designed to talk over USB to a Python program on the > host computer. The peripheral is spewing

Re: Efficient handling of fast, real-time hex data

2016-05-31 Thread Michael Torrie
On 05/31/2016 06:20 PM, jlada...@itu.edu wrote: > So, how can I take the byte sequence <0x01 0x02 0x03 0x04 0x05 0x06 > \n> that Serial.readline() returns to me, and QUICKLY turn it into > three integer values, 258, 772, and 1286? Better yet, can I write > these bytes directly into an array (numpy

Efficient handling of fast, real-time hex data

2016-05-31 Thread jladasky
Greetings everyone, I'm developing small embedded systems. I can't use Python to program them, I have to program the little CPU's in C. I want a peripheral I've designed to talk over USB to a Python program on the host computer. The peripheral is spewing data at a reasonably high rate, abou

Re: [OFF-TOPIC] It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code?

2014-11-06 Thread mbg1708
On Tuesday, 4 November 2014 16:49:36 UTC, françai s wrote: > I intend to write in lowest level of computer programming as a hobby. > > It is true that is impossible write in binary code, the lowest level > of programming that you can write is in hex code? > > What is t

Re: [OFF-TOPIC] It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code?

2014-11-06 Thread William Ray Wing
> On Nov 5, 2014, at 6:14 PM, Clayton Kirkwood wrote: > > Yeah, the 11 was mesmerizing. You didn't need no stinkin' program to see how > busy the system was, you just checked the lights. You could really tell when > somebody was compiling or link/loading. As I've done many times since those > da

RE: [OFF-TOPIC] It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code?

2014-11-06 Thread Clayton Kirkwood
:python-list- >bounces+crk=godblessthe...@python.org] On Behalf Of Cameron Simpson >Sent: Wednesday, November 05, 2014 2:28 PM >To: python-list@python.org >Subject: Re: [OFF-TOPIC] It is true that is impossible write in binary >code, the lowest level of programming that you can wr

Re:[OFF-TOPIC] It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code?

2014-11-05 Thread Dave Angel
françai s Wrote in message: > I intend to write in lowest level of computer programming as a hobby. > > It is true that is impossible write in binary code, the lowest level > of programming that you can write is in hex code? > > What is the lowest level of programming comp

Re: [OFF-TOPIC] It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code?

2014-11-05 Thread Cameron Simpson
On 05Nov2014 18:09, Chris Angelico wrote: On Wed, Nov 5, 2014 at 5:39 PM, Cameron Simpson wrote: Bah! He asked if there were lower levels than binary. Ergo: chip design! (And microcode, the intermediate layer. Or one of the layers, depending where you draw the line.) Should we stop before we r

Re: [OFF-TOPIC] It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code?

2014-11-05 Thread Dan Stromberg
On Tue, Nov 4, 2014 at 10:39 PM, Cameron Simpson wrote: > Bah! He asked if there were lower levels than binary. Ergo: chip design! > (And microcode, the intermediate layer. Or one of the layers, depending > where you draw the line.) Should we stop before we reach the quantum foam of > spacetime?

Re: [OFF-TOPIC] It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code?

2014-11-05 Thread Cameron Simpson
On 05Nov2014 15:38, Denis McMahon wrote: On Tue, 04 Nov 2014 21:30:06 -0500, Dennis Lee Bieber wrote: If you have an old system with front-panel toggle switches, you set the switches for binary values, and then push the "enter" switch. You've booted a PDP-8 then ;) Not me, but I hav

Re: [OFF-TOPIC] It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code?

2014-11-05 Thread MRAB
in hex code? What is the lowest level of programming computers that you can write ? Is binary code? Is hex code? Is another machine code? Honestly do not know if it is true that there is another machine code beyond the binary and hex code. Is Assembly? Meaningless question -- it all

Re: [OFF-TOPIC] It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code?

2014-11-05 Thread Denis McMahon
On Tue, 04 Nov 2014 21:30:06 -0500, Dennis Lee Bieber wrote: > If you have an old system with front-panel toggle switches, you set the > switches for binary values, and then push the "enter" switch. You've booted a PDP-8 then ;) -- Denis McMahon, denismfmcma...@gmail.com -- https://mail

Re: [OFF-TOPIC] It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code?

2014-11-05 Thread Chris Angelico
On Thu, Nov 6, 2014 at 2:05 AM, Grant Edwards wrote: > On 2014-11-05, Dennis Lee Bieber wrote: > >> "machine code" typically implies an instruction set specific >> to that machine... ALL computers operate in BINARY logic (a bit only >> holds 0 or 1). How you get those bits into the computer is >

Re: [OFF-TOPIC] It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code?

2014-11-05 Thread Grant Edwards
On 2014-11-05, Dennis Lee Bieber wrote: > "machine code" typically implies an instruction set specific > to that machine... ALL computers operate in BINARY logic (a bit only > holds 0 or 1). How you get those bits into the computer is > irrelevant. Just to muddy the water... _Most_ parts of mo

Re: [OFF-TOPIC] It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code?

2014-11-04 Thread Chris Angelico
On Wed, Nov 5, 2014 at 5:39 PM, Cameron Simpson wrote: > Bah! He asked if there were lower levels than binary. Ergo: chip design! > (And microcode, the intermediate layer. Or one of the layers, depending > where you draw the line.) Should we stop before we reach the quantum foam of > spacetime? C

Re: [OFF-TOPIC] It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code?

2014-11-04 Thread Cameron Simpson
ason why someone would WANT >to program in binary/hex machine code. It happens if you design yourself a specialized microcoded machine, also known as a number cruncher and you dont want to developp assembly tools to program it. So you have to fill a memory with 0 and 1 It's sometimes the wo

Re: [OFF-TOPIC] It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code?

2014-11-04 Thread Chris Angelico
On Wed, Nov 5, 2014 at 1:30 PM, Dennis Lee Bieber wrote: > "machine code" typically implies an instruction set specific to that > machine... ALL computers operate in BINARY logic (a bit only holds 0 or 1). > How you get those bits into the computer is irrelevant. Bah, those zeroes and one

Re: [OFF-TOPIC] It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code?

2014-11-04 Thread Theo van Werkhoven
t is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code? What is the lowest level of programming computers that you can write ? Is binary code? Is hex code? Is another machine code? Honestly do not know if it is true that there is ano

Re: [OFF-TOPIC] It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code?

2014-11-04 Thread Grant Edwards
On 2014-11-04, ast wrote: > > a écrit dans le message de > news:e5c95792-f81f-42b4-9996-5545f5607...@googlegroups.com... > On Tuesday, November 4, 2014 8:49:36 AM UTC-8, françai s wrote: > > >>I can't think of any reason why someone would WANT >>to program

Re: [OFF-TOPIC] It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code?

2014-11-04 Thread Tobiah
On 11/04/2014 08:45 AM, françai s wrote: I intend to write in lowest level of computer programming as a hobby. It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code? What is the lowest level of programming computers that you can

Re: [OFF-TOPIC] It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code?

2014-11-04 Thread sohcahtoa82
ould WANT > >to program in binary/hex machine code. > > It happens if you design yourself a specialized microcoded > machine, also known as a number cruncher and you dont > want to developp assembly tools to program it. So you > have to fill a memory with 0 and 1 > It&

Re: [OFF-TOPIC] It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code?

2014-11-04 Thread ast
a écrit dans le message de news:e5c95792-f81f-42b4-9996-5545f5607...@googlegroups.com... On Tuesday, November 4, 2014 8:49:36 AM UTC-8, françai s wrote: I can't think of any reason why someone would WANT to program in binary/hex machine code. It happens if you design yours

Re: [OFF-TOPIC] It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code?

2014-11-04 Thread sohcahtoa82
On Tuesday, November 4, 2014 8:49:36 AM UTC-8, françai s wrote: > I intend to write in lowest level of computer programming as a hobby. > > It is true that is impossible write in binary code, the lowest level > of programming that you can write is in hex code? > > What is t

Re: [OFF-TOPIC] It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code?

2014-11-04 Thread sjmsoft
Grant's statements are correct and his advice is sound. I would not waste my time writing machine code, even as a hobby (and not even if your other hobbies include juggling chain saws). It's too time-consuming, tedious, bug-prone, and eyeglass-prescription-enhancing. Programming in assembly la

Re: [OFF-TOPIC] It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code?

2014-11-04 Thread Rustom Mody
On Tuesday, November 4, 2014 10:19:36 PM UTC+5:30, françai s wrote: > I intend to write in lowest level of computer programming as a hobby. > > It is true that is impossible write in binary code, the lowest level > of programming that you can write is in hex code? > > What is t

Re: [OFF-TOPIC] It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code?

2014-11-04 Thread Grant Edwards
a nice simple, regular, orthogonal instruction set. That will minimize the amount of stuff you'll need to memorize. The MSP430 isn't bad either. > the lowest level of programming that you can write is in hex code? Hex is just a shorthand notation for binary where a group of 4 bits

[OFF-TOPIC] It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code?

2014-11-04 Thread françai s
I intend to write in lowest level of computer programming as a hobby. It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code? What is the lowest level of programming computers that you can write ? Is binary code? Is hex code? Is

Re: Creating a 2s compliment hex string for negitive numbers

2014-08-01 Thread bSneddon
On Friday, August 1, 2014 4:47:20 PM UTC-4, MRAB wrote: > On 2014-08-01 21:35, bSneddon wrote: > > > I need to calculate an error correction code for an old protocol. > > > > > > I calculate the integer 4617 and want to code the 2s compliment in ASCII > > &

Re: Creating a 2s compliment hex string for negitive numbers

2014-08-01 Thread MRAB
On 2014-08-01 21:35, bSneddon wrote: I need to calculate an error correction code for an old protocol. I calculate the integer 4617 and want to code the 2s compliment in ASCII hex EDF7. When issue the following. hex(-4617) '-0x1209' Does anyone know a clean way to get to the desir

Creating a 2s compliment hex string for negitive numbers

2014-08-01 Thread bSneddon
I need to calculate an error correction code for an old protocol. I calculate the integer 4617 and want to code the 2s compliment in ASCII hex EDF7. When issue the following. >>> hex(-4617) '-0x1209' Does anyone know a clean way to get to the desired results? My ECC wi

Re: converting strings to hex

2014-04-04 Thread Mark H Harris
On 4/4/14 5:36 PM, Chris Angelico wrote: If someone is asking for a hint, it's because s/he is trying to learn. I'm always willing to help someone learn, regardless of whether they're going through a course or currently employed or whatever. Sometimes a small hint can be obtained from the interpr

Re: converting strings to hex

2014-04-04 Thread Chris Angelico
On Sat, Apr 5, 2014 at 8:33 AM, Mark H Harris wrote: > On 4/4/14 1:16 AM, James Harris wrote: >> >> YMMV but I thought the OP had done a good job before asking for help and >> then asked about only a tiny bit of it. Some just post a question! > > >Indeed they do. Its a little like negotiating

Re: converting strings to hex

2014-04-04 Thread Mark H Harris
On 4/4/14 1:16 AM, James Harris wrote: YMMV but I thought the OP had done a good job before asking for help and then asked about only a tiny bit of it. Some just post a question! Indeed they do. Its a little like negotiating with terrorists. As soon as you negotiate with the first one, you

Re: converting strings to hex

2014-04-04 Thread alister
On Thu, 03 Apr 2014 21:38:38 -0500, Mark H Harris wrote: > On 4/3/14 9:10 PM, dave em wrote: >> >> I am taking a cryptography class and am having a tough time with an >> assignment similar to this. >> >> > hi Dave, if your instructor wanted you to work on this with other people > she would have ma

Re: converting strings to hex

2014-04-04 Thread Mark Lawrence
On 04/04/2014 04:22, dave em wrote: You haven't seen nothing yet, wait till M.L. catches you on the flip side for using gg. {running for cover} Who is ML? Good morning :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark

Re: converting strings to hex

2014-04-03 Thread James Harris
"Mark H Harris" wrote in message news:533e1b2e.5040...@gmail.com... > On 4/3/14 9:10 PM, dave em wrote: >> >> I am taking a cryptography class and am having a >> tough time with an assignment similar to this. >> > > hi Dave, if your instructor wanted you to work on this with other people > she w

Re: converting strings to hex

2014-04-03 Thread dave em
> You haven't seen nothing yet, wait till M.L. catches you on the flip > > side for using gg. {running for cover} Who is ML? -- https://mail.python.org/mailman/listinfo/python-list

Re: converting strings to hex

2014-04-03 Thread Mark H Harris
On 4/3/14 10:10 PM, dave em wrote: Thanks, got it. Sometimes the simple things can be difficult. Dave You haven't seen nothing yet, wait till M.L. catches you on the flip side for using gg. {running for cover} marcus -- https://mail.python.org/mailman/listinfo/python-list

Re: converting strings to hex

2014-04-03 Thread dave em
; > turn the string into a float. > > > > For the record, "c1" in your example should be an integer/long > > > > It sounds like you want the optional parameter to int() so you'd do > > > > >>> hex_string = "My text message".encode(&q

Re: converting strings to hex

2014-04-03 Thread Mark H Harris
On 4/3/14 9:10 PM, dave em wrote: I am taking a cryptography class and am having a tough time with an assignment similar to this. hi Dave, if your instructor wanted you to work on this with other people she would have made it a group project and ordered pizza for everyone. I'll give you so

Re: converting strings to hex

2014-04-03 Thread Tim Chase
sounds like you want the optional parameter to int() so you'd do >>> hex_string = "My text message".encode("hex") >>> hex_string '4d792074657874206d657373616765' >>> m1 = int(hex_string, 16) # magic happens here >

converting strings to hex

2014-04-03 Thread dave em
fast. I could use a little help on this one. So my first step is to compute the key. I suspect my error below is because c1 is a float and m1 is a string but I don't know how to turn the string into a float. Python 2.7### m1text="my test message" print( m1text + '

Re: inconsistency in converting from/to hex

2013-11-17 Thread Serhiy Storchaka
17.11.13 08:31, Steven D'Aprano написав(ла): There's already at least two ways to do it in Python 2: py> import binascii py> binascii.hexlify('Python') '507974686f6e' py> import codecs py> codecs.encode('Python', 'hex') '5079

Re: inconsistency in converting from/to hex

2013-11-17 Thread Mark Lawrence
On 17/11/2013 06:31, Steven D'Aprano wrote: I agree that its a bit of a mess. But only a little bit, and it will be less messy by 3.5 when the codecs solution is re-introduced. Then the codecs.encode and decode functions will be the one obvious way. For anyone who's interested in the codecs i

Re: inconsistency in converting from/to hex

2013-11-16 Thread Steven D'Aprano
tion to the given problem. bytes.fromhex is very useful, because when working with binary data it is common to give data as strings of hex values, and so it is good to have a built-in method for it: image = bytes.fromhex('ffd8ffe000104a464946000101 ...') On the other hand, converting bytes to

Re: inconsistency in converting from/to hex

2013-11-16 Thread Ned Batchelder
On Saturday, November 16, 2013 5:16:58 PM UTC-5, Laszlo Nagy wrote: > We can convert from hex str to bytes with bytes.fromhex class method: > > >>> b = bytes.fromhex("ff") > > But we cannot convert from hex binary: > > >>> b = bytes.

inconsistency in converting from/to hex

2013-11-16 Thread Laszlo Nagy
We can convert from hex str to bytes with bytes.fromhex class method: >>> b = bytes.fromhex("ff") But we cannot convert from hex binary: >>> b = bytes.fromhex(b"ff") Traceback (most recent call last): File "", line 1, in TypeError: must be st

Re: Converting hex data to image

2013-11-14 Thread Shyam Parimal Katti
Perfect. Thank you @Ben and @Tim On Thu, Nov 14, 2013 at 4:29 PM, Ben Finney wrote: > Ben Finney writes: > > > To turn a byte string into a file-like object for use with PIL, extract > > the byte string as ‘image_data’, use the standard library ‘io.StringIO’ > > class http://docs.python.org/3/l

Re: Converting hex data to image

2013-11-14 Thread Ben Finney
Ben Finney writes: > To turn a byte string into a file-like object for use with PIL, extract > the byte string as ‘image_data’, use the standard library ‘io.StringIO’ > class http://docs.python.org/3/library/io.html#io.StringIO>, then > create a new ‘PIL.Image’ object by reading from that pseudo-

Re: Converting hex data to image

2013-11-14 Thread Ben Finney
Shyam Parimal Katti writes: > When we fetch the data from the LDAP server for a particular valid > user, the data associated with the user contains the thumbnail photo > in hex representation. E.x.: > > [('CN=XX,OU=Users,OU=Accounts,DC=test,DC=com', {'msExc

Re: Converting hex data to image

2013-11-14 Thread Tim Golden
On 14/11/2013 15:32, Shyam Parimal Katti wrote: > I am implementing an authentication system(in Django) using LDAP as the > backend(django-auth-ldap). When we fetch the data from the LDAP server > for a particular valid user, the data associated with the user contains > the thumbnail

Converting hex data to image

2013-11-14 Thread Shyam Parimal Katti
I am implementing an authentication system(in Django) using LDAP as the backend(django-auth-ldap). When we fetch the data from the LDAP server for a particular valid user, the data associated with the user contains the thumbnail photo in hex representation. E.x.: [('CN=XX,OU=Users,OU=Accoun

Re: HEX to ASCII

2013-10-08 Thread Mark Lawrence
to another. i mostly use it for HEX to BIN and vice versa, but it supports other bases too. That's nice to know, but what has it got to do with the market price of oranges in Timbuktu? Or to put it another way, you're forcing volunteers to go and find your original message as once again

Re: HEX to ASCII

2013-10-08 Thread markotaht
esmaspäev, 7. oktoober 2013 17:16.29 UTC+3 kirjutas Mark Lawrence: > On 07/10/2013 14:54, markot...@gmail.com wrote: > > > I forgot to tell. The teisendaja module that i have imported, is a number > > converter that allow to convert numbers from one base to another. i mostly

Re: HEX to ASCII

2013-10-08 Thread markotaht
esmaspäev, 7. oktoober 2013 18:52.21 UTC+3 kirjutas Piet van Oostrum: > markot...@gmail.com writes: > > > > > This is the code i came up with: > > > from teisendaja import * > > > from operator import * > > > import binascii > > > > > > teisendus = teisendus() > > > kood = input("Kood: ")

Re: HEX to ASCII

2013-10-07 Thread Piet van Oostrum
markot...@gmail.com writes: > This is the code i came up with: > from teisendaja import * > from operator import * > import binascii > > teisendus = teisendus() > kood = input("Kood: ") > key = input("Võti: ") > > chunksize = 2 > vastus = [teisendus.teisendus3(16,2,kood[i: (i + chunksize)]) for i

Re: HEX to ASCII

2013-10-07 Thread Mark Lawrence
On 07/10/2013 14:54, markot...@gmail.com wrote: I forgot to tell. The teisendaja module that i have imported, is a number converter that allow to convert numbers from one base to another. i mostly use it for HEX to BIN and vice versa, but it supports other bases too. That's nice to

Re: HEX to ASCII

2013-10-07 Thread markotaht
I forgot to tell. The teisendaja module that i have imported, is a number converter that allow to convert numbers from one base to another. i mostly use it for HEX to BIN and vice versa, but it supports other bases too. -- https://mail.python.org/mailman/listinfo/python-list

Re: HEX to ASCII

2013-10-07 Thread markotaht
, b'_', b'\x1e', > > b',', b'j', b'\x0c', b'\x08', b'i', b'(', b'\x06', b'\\', b'r', b'3', > > b'\x1f', b'V', b's', b'9

Re: HEX to ASCII

2013-10-06 Thread Piet van Oostrum
\\', b'r', b'3', > b'\x1f', b'V', b's', b'9', b'\x1d'] > > the Key- is the key im using to decrypt the code. everything else is > generated by the decrytion process and the unhexlify command. So my guess is, > the join command cant handle the b"u" type of format. how can i get rid of > the b. > > Or does anyone have a better idea how to translate HEX into ASCII and sort > out the lines that make sense Why do you post the same question twice under different subjects? -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

  1   2   3   4   5   6   >