Study/Python

펌웨어 바이너리 파일 등 hexadecimal 값을 가독성이 좋은 형태로 변환해야 하는 경우가 있다.

 

예를들면

0x00 0x11 0x22 ...  => 001122 의 형태로

 

간단하게

import binascii

binascii.hexlify(), binascii.unhexlify()를 활용하면 된다.

 

 

의 결과 값은 아래와 같다.

 

 

character '1'의 hex 값은 0x31이다.

http://www.asciitable.com/

 

Ascii Table - ASCII character codes and html, octal, hex and decimal chart conversion

ASCII Table and Description ASCII stands for American Standard Code for Information Interchange. Computers can only understand numbers, so an ASCII code is the numerical representation of a character such as 'a' or '@' or an action of some sort. ASCII was

www.asciitable.com

 

 

만약 특정 바이너리 파일을 모두 컨버팅 하기 위해서는 아래와 같이 하면 된다.

결과.

 

'Study > Python' 카테고리의 다른 글

python 함수 주기적으로 실행하기  (0) 2017.01.25
python Queue 사용방법  (0) 2017.01.25