Questions tagged [binascii]
50 questions
0
votes
0 answers
unhexlify always needs pairs
I have a simple piece of Python code where I want to xor two hex strings
and unhexlify the result as below
def _xor(s1, s2):
return hex(int(s1, 16) ^ int(s2, 16))[2:]
if __name__ == "__main__":
…

Glenn Pierce
- 720
- 1
- 6
- 18
0
votes
1 answer
CRC32 in binascii.crc32 outputs variable checksum length: 8-9-10 digits
Is it correct behavior that binascii.crc32 outputs different checksum lengths: sometimes 8 digits, sometimes 9 or 10. I use it for an array of bytes: <700 bytes.
The…

Mr D
- 23
- 5
0
votes
1 answer
Convert Python's binascii.crc_hqx() back to ascii
I'm using the standard Python3 lib binascii, and specifically the crc_hqx() function
binascii.crc_hqx(data, value)
Compute a 16-bit CRC value of data, starting with value as the initial CRC, and return the result. This uses the CRC-CCITT polynomial…

philshem
- 24,761
- 8
- 61
- 127
0
votes
2 answers
Conversion of pysnmp OctetString to hex in python3
I have written python code that sends snmp get to a device using pysnmp then convert the output to an hex string. The code works successfully in python 2.7 but it does not in Python3.7
In both python2.7 and python3.7 the snmp get returns an…

Bassosimons
- 11
- 1
- 4
0
votes
1 answer
Hex to Bin: Odd-length string error with binascii.unhexlify
I want to convert a Hex file like this file in the bottom to Binary, but I give this error: I think I need to use .strip() method but I'm not very sure!
Traceback (most recent call last):
File ".\descrypt.py", line 27, in
main()
…
user10387539
0
votes
1 answer
Python crc_hqx(data, value) proper implementation
Solved! Thank you rcgdlr.
I am just learning about CRCs and am unsure my implementation is correct. I have a number of questions:
Do I include the crc in the data portion (I believe I do but I'm unsure; could it depend on the…

Bix
- 760
- 8
- 22
0
votes
0 answers
How to store the data in little endian format in a binary file in Python
I have a binary file. I want to read hexadecimal data from the terminal in my python code. I am executing the program as follows:
python hello.py "2DB6C" "CDEF"
"2DB6C" :- (Address in hex) Indicates GoTo address <2DB6C> in the temp.bin file, where I…

ANURAG MODI
- 33
- 1
- 7
0
votes
0 answers
Text to Hexadecimal Binary format for Binary File Search Query
I need to search a binary file for particular strings. The strings come from a word list in a text file. I think it would be easier to translate the words from the text file into a format that can then be searched. The format that I need to…

Joshua Faust
- 306
- 2
- 16
0
votes
1 answer
Pyserial reading does not respect the number of bites
I am trying to read-out a serial port.
The problem is that the script works but the read command seems to not respect the argument (2 bytes to read).
The typical output of the script (the ans variable in return function "readPosValue")…

Raizen
- 99
- 2
- 10
0
votes
1 answer
Python invalid literal for int() with base 2
I'm trying a simple steganography python program. Encoding works, but I got the error ValueError: invalid literal for int() with base 2: '0b#99c1f#......
The value should be binary and I can't find the error. I'm using python 2.7 an this is the…

muex
- 120
- 1
- 2
- 7
0
votes
1 answer
Convert a string to hexadecimal in Python
Here is my function who build the message from an array.
There are two type of checks:
Check "C", "G", "A" -> [("{'chip_id': '00012345', 'check_type': 'C'}", 1494273855.0)]
Check "P" -> ["{'latitude': 43.5529109, 'longitude': 1.4910036,…

Damien Brz
- 27
- 1
- 11
0
votes
1 answer
I can't convert hex to string in Python
So I've done this code(this is just the part where it transforms the string into hex), and when I try to decrypt I get this message: Non-hexadecimal digit found
Here is string to hex code:
def password (pslen):
alphabet =…

Tudor Ienesoi
- 23
- 3
0
votes
1 answer
Decode in Python
I am trying to discover text encoded in ASCII found within a DNA sequence from a file.
Below is my code:
The first is to open the FASTA file and set is a variable.
with open("/home//python/progseq") as mydnaseq:
sequence =…

Young Autobot
- 81
- 10
0
votes
2 answers
Correct interpretation of hex byte, convert it to float
I am currently trying to connect to an electric meter via RS485.
It works quite well so far, except that I have problems reading what the meter is writing back on the RS485 line.
I know that the data from the electric meter is correct since I can…

Max
- 13
- 5
0
votes
1 answer
Python - Binascii Error while unhexlify
I am reading out a file, calculate the ord-number which can be used together with the ord() function.
After that I unhexlify this number to get the byte representation of this character, because I work with non-ASCII characters and write these into…

freedome97
- 167
- 3
- 15