How to concatenate two arbitrary long hex values?

Question:

I have two variables.
Variable A contains 1024 bytes (not always ascii characters, arbitrary hex values)
Variable B contains 64 bytes (not always ascii characters, arbitrary hex values)

How can I generate a variable C such that C = A || B ? (|| means concatenation)

Asked By: drdot

||

Answers:

ummmm

A = 'x04x05x06'
B = 'x04x05x06'

C = A + B
Answered By: Joran Beasley

The + operator works on bytes too:

>>> b'x12x14' + b'x16x0b'
b'x12x14x16x0b'
Answered By: phihag

to the last comment, if you try using in the print (C) function it does not work.. ummm its missing something..
you would need to revert to the previous comment before that being
for it to actually work.

A = b’x12x14′
B = b’x16x0b’

C = A + B
print (C)

Answered By: KurtA
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.