๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿงก ์ œํ’ˆ ๋ฆฌ๋ทฐ ๋ฐ ์ด๊ฒƒ์ €๊ฒƒ

0x55์™€ 0xAA

by devshin.kr 2021. 5. 18.
728x90

๋ฉ”๋ชจ๋ฆฌ ํ•ดํ‚น์— ๋Œ€๋น„ํ•ด ์‚ฌ์šฉ์ž์˜ ๋น„๋ฐ€๋ฒˆํ˜ธ์™€ ๊ฐ™์€ ๊ฐ’์„ String์—์„œ byte[]๋กœ ๋ฐ›์•„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ์ข‹์„ ์ˆ˜ ์žˆ๋‹ค.
์ด์— ๋”ฐ๋ผ byte[]๋กœ ๋ฐ›์€ ๊ฐ’์€ ์‚ฌ์šฉ์ด ๋๋‚œ ํ›„์— 0x00 ๊ณผ ๊ฐ™์€ ์“ฐ๋ ˆ๊ธฐ ๊ฐ’์œผ๋กœ ๋ฎ์–ด ์“ฐ๋„๋ก ํ•œ๋‹ค.
๊ทธ๋Ÿฐ๋ฐ 0x55 , 0xAA ์™€ ๊ฐ™์€ ๊ฐ’์œผ๋กœ ๋ฎ์–ด ์“ฐ๋Š” ๊ฒฝ์šฐ๊ฐ€ ์žˆ๋Š”๋ฐ, ์ด ๊ฐ’์ด ๋ญ”๊ฐ€ ํŠน์ •ํ•œ ์˜๋ฏธ๊ฐ€ ์žˆ๋Š” ๊ฐ’์ธ๊ฐ€ ํ•˜์—ฌ ์ฐพ์•„ ๋ดค๋‹ค.
๋งˆ์นจ ๋”ฑ 0x55, 0xAA๋ฅผ ์ •๋ฆฌํ•œ ๋ธ”๋กœ๊ทธ๊ฐ€ ์žˆ์–ด ๊ณต์œ ํ•œ๋‹ค.

0x55๋Š” ๋ฐ”์ด๋„ˆ๋ฆฌ ํ‘œ๊ธฐ๋ฒ•์œผ๋กœ 01010101์ด๋‹ค.
0xAA๋Š” ๋ฐ”์ด๋„ˆ๋ฆฌ ํ‘œ๊ธฐ๋ฒ•์œผ๋กœ 10101010์ด๋‹ค.

์•„๋ž˜์˜ ๋ธ”๋กœ๊ทธ์—์„œ๋„ ์ด ๊ฐ’์ด ํฐ ๋น„๋ฐ€์„ ๊ฐ€์ง„ ๊ฐ’์ด๋ผ๊ณ  ํ•˜์ง€๋Š” ์•Š๋Š”๋‹ค.


Out of curiosity, I did some research about 0x55 and 0xAA. It turned out not a big secret at all. Decades ago, the programmers choose them may simply because 0x55 in binary notation is 01010101. And 0xAA in binary notation is 10101010.
You can think of 01010101 and 10101010 as a signature. It helps computers recognize the program.

https://medium.com/@iotapioneer/55-and-aa-8c06b8719c1

 

55 and AA

What’s special about 55 and AA? Or more specifically, 0x55 and 0xAA?

medium.com

 

๋Œ“๊ธ€