For example,
If I open a file using hex editor, it showed
3C 47 23 56 59 59 66 38 38 5C 67 3A 5A 70 29 32 47 25 28 63 5D 33 32 39 69 30 58 53 2B 4B 44 61 45 27 7A 3F 21 64 76 5B 54 5D 28 46 75 7A 52 5F
How can I get it as "string"?
Should I do below?
---------------------------------------------
hfile1 = open("example1.txt", "rb")
bfile1 = hfile1.read()
----------------------------------------------
But if I use my code above, then I search regex using my code below:
----------------------------------------------
afile1 = re.findall('[0-9A-Fa-f]{2}', bfile1)
----------------------------------------------
There will be error:
TypeError: cannot use a string pattern on a bytes-like object
Then If I modify my regex search using below:
----------------------------------------------
afile1 = re.findall(b'[0-9A-Fa-f]{2}', bfile1)
----------------------------------------------
The regex search result will do regex to String part (Decoded Text) of hex editor:
<G#VYYf88\g:Zp)2G%(c]329i0XS+KDaE'z?!dv[T](FuzR_
So the result is not as I expected
Thank You
If I open a file using hex editor, it showed
3C 47 23 56 59 59 66 38 38 5C 67 3A 5A 70 29 32 47 25 28 63 5D 33 32 39 69 30 58 53 2B 4B 44 61 45 27 7A 3F 21 64 76 5B 54 5D 28 46 75 7A 52 5F
How can I get it as "string"?
Should I do below?
---------------------------------------------
hfile1 = open("example1.txt", "rb")
bfile1 = hfile1.read()
----------------------------------------------
But if I use my code above, then I search regex using my code below:
----------------------------------------------
afile1 = re.findall('[0-9A-Fa-f]{2}', bfile1)
----------------------------------------------
There will be error:
TypeError: cannot use a string pattern on a bytes-like object
Then If I modify my regex search using below:
----------------------------------------------
afile1 = re.findall(b'[0-9A-Fa-f]{2}', bfile1)
----------------------------------------------
The regex search result will do regex to String part (Decoded Text) of hex editor:
<G#VYYf88\g:Zp)2G%(c]329i0XS+KDaE'z?!dv[T](FuzR_
So the result is not as I expected
Thank You