μœ„μ™€ 같이 μ–΄λ–€ μ„œλΉ„μŠ€μ— λŒ€ν•œ νšŒμ›κ°€μž…μ„ μˆ˜ν–‰ν•˜κ±°λ‚˜ λΉ„λ°€λ²ˆν˜Έ 찾기와 같은 κΈ°λŠ₯을 μˆ˜ν–‰ν–ˆμ„κ²½μš° 인증 κ΄€λ ¨ 메일이 λ°œμ†‘λ˜λŠ” 것을 자주 확인할 수 μžˆμŠ΅λ‹ˆλ‹€. κ·ΈλŸ¬λ‚˜ μœ„μ™€ 같이 인증확인 λ²„νŠΌμ„ ν΄λ¦­ν–ˆμ„λ•Œ μ–΄λ– ν•œ λ™μž‘μ„ ν•˜λŠ”μ§€ κΆκΈˆν•˜μ‹œμ§€ μ•ŠμœΌμ‹ κ°€μš”? μœ„μ™€ 같은 인증 λ²„νŠΌμ€ 링크 μ—˜λ¦¬λ¨ΌνŠΈλ‘œ λ˜μ–΄μžˆμœΌλ©° 일반적인 GET μš”μ²­μž…λ‹ˆλ‹€. 그리고 κ·Έ URIμ—λŠ” λ‹€μŒκ³Ό 같은 μ–΄λ– ν•œ ν˜•νƒœμ˜ λ¬Έμžμ—΄μ΄ ν¬ν•¨λ˜κ²Œ λ©λ‹ˆλ‹€.

a2RldmtyQGdtYWlsLmNvbTp5Rm5iTUtrblZrRW85ckdxTVlmTGtWNE03UUtMTldXWg==

μœ„μ™€ 같이 κ΅¬μ„±λœ λ¬Έμžμ—΄μ€ Base64둜 μΈμ½”λ”©λœ 데이터이며 크둬 κ°œλ°œμžλ„κ΅¬μ˜ μ½˜μ†”μ„ 톡해 이 μ•„μŠ€ν‚€ λ¬Έμžμ—΄μ„ λ””μ½”λ”©ν•˜λ©΄ λ‹€μŒκ³Ό 같은 λ¬Έμžμ—΄ 데이터λ₯Ό 확인할 수 μžˆμŠ΅λ‹ˆλ‹€.

atob("a2RldmtyQGdtYWlsLmNvbTp5Rm5iTUtrblZrRW85ckdxTVlmTGtWNE03UUtMTldXWg==")
'kdevkr@gmail.com:yFnbMKknVkEo9rGqMYfLkV4M7QKLNWWZ'

제 이메일 μ£Όμ†Œμ™€ ν•¨κ»˜ μ–΄λ– ν•œ λ¬Έμžμ—΄μ„ ν¬ν•¨ν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€. μ•„λ§ˆλ„ μ € μ•Œμˆ˜μ—†λŠ” λ¬Έμžμ—΄μ€ μ•”ν˜Έν™”λœ 인증 정보일 κ²ƒμž…λ‹ˆλ‹€. 인증 정보와 GET μš”μ²­μ— ν¬ν•¨λœ 이메일 μ£Όμ†Œκ°€ λ™μΌν•œμ§€λ₯Ό λ‚΄λΆ€μ μœΌλ‘œ κ²€μ¦ν•˜κ² μ£ . μ΄λŸ¬ν•œ 인증 정보λ₯Ό μ™œ Base64둜 μΈμ½”λ”©ν•˜μ—¬ μ „μ†‘ν•˜κ²Œ λ˜λŠ” κ²ƒμΌκΉŒμš”? μ•ˆμ „ν•œ ν˜•νƒœλ‘œ 데이터λ₯Ό μ „λ‹¬ν•˜κ³ μžν•˜λŠ” λͺ©μ μ— μžˆμŠ΅λ‹ˆλ‹€.

μ•„μŠ€ν‚€ μ½”λ“œ

μ‚¬λžŒλ“€μ€ 수 λ§Žμ€ 문자의 ν˜•νƒœλ₯Ό 읽고 ꡬ뢄할 수 μžˆμ§€λ§Œ 0κ³Ό 1둜 이루어진 컴퓨터 μ‹œμŠ€ν…œμ€ μ‹œμŠ€ν…œμ— 따라 0κ³Ό 1을 읽고 κ΅¬λΆ„ν•˜λŠ” 방식이 λ‹€λ₯Ό 수 μžˆμŠ΅λ‹ˆλ‹€. μ‹œμŠ€ν…œμ˜ λ°œμ „μ— 따라 μ•„μŠ€ν‚€ μ½”λ“œλΆ€ν„° μœ λ‹ˆμ½”λ“œ 그리고 μ—¬λŸ¬κ°€μ§€ 문자 쑰합이 ν™•μž₯되고 μžˆμŠ΅λ‹ˆλ‹€. λŒ€λΆ€λΆ„μ˜ 문자 ν˜•μ‹μ€ μ•„μŠ€ν‚€ μ½”λ“œλ₯Ό 기초둜 λ§Œλ“€μ–΄μ§€κΈ° λ•Œλ¬Έμ— μ•„μŠ€ν‚€ μ½”λ“œ 쀑 일뢀 문자 집합은 거의 λͺ¨λ“  μ‹œμŠ€ν…œμ—μ„œ κ³΅ν†΅μœΌλ‘œ μ‚¬μš©λ˜λŠ” λ¬Έμžμž…λ‹ˆλ‹€. κ·ΈλŸ¬ν•œ λ¬Έμžλ“€μ„ λͺ¨μ•„ λ§Œλ“€μ–΄μ§€λŠ”κ²Œ Base64 μΈμ½”λ”©μž…λ‹ˆλ‹€.

Base64 이미지

λΈŒλΌμš°μ €μ—μ„œλŠ” λ°”μ΄λ„ˆλ¦¬ 데이터 뿐만 μ•„λ‹ˆλΌ Base64둜 이루어진 이미지 데이터λ₯Ό ν‘œν˜„ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

<img data-src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAAAXNSR0IArs4c6QAAA+VJREFUeF7tnclu4zAUBEf//9EeYG6SAhUKTdJUpnMV1663kbKd4/P5fP70bxsFjgLZhsW/hRTIXjwKZDMeBVIguymw2XqaQwpkMwU2Ww56yHEcS5d8PRZd56djU9p+9mZx/XQOKZCxiAoELiK+bXBX3A1ZXw7JMRByOevgFPNTC6b10vx2PzeBL8BxPTaH0IB2AyRIgVwUJcEsAGtBBVIgqY2d+luD1kmdzgm0G+pPIdF6jB2P1jd9f2kOSQXSFiSrogIBEyILtAJai52dw+L91UPOV0MkqDUAHQHeBsRaOAlIgi0PyQVSD4nKwnoIHP1Xu3SBfBkIxfgUEI2/2uC2PxiSYAVyeb8w24IKRN5lFchZMDrH4ME3LXupzqfn5AH2+XU+FEC+r6D9xCG0QJ7PIRZAgcBlYz1EmpQNSRSj/7uQJfXWzUnw2c/1gmUH9FibQ+T8uvlswWl8vWDZoUAG3zRI/W/NC+S3AUktIu1PST8tM9P1je6Pd1mjJ7TjFYhVbHL7ApkssB2+QOBykQTFK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XYti+QzT+XRRZWD7EmL9vXQ0YX0hJAm58VwHfqFWytAgWyVm+crUBQorUNCmSt3jhbgaBEaxsUyFq9cbYCQYnWNvgLqC4vPjN7siAAAAAASUVORK5CYII=" data-loaded="true">

Base64둜 ν‘œμ‹œλœ QRμ½”λ“œ 이미지

μ›ΉνŒ©μ˜ url-loaderλŠ” μœ„μ™€ 같은 Base64 ν˜•μ‹μ˜ URI둜 λ³€ν™˜ν•©λ‹ˆλ‹€.

HTTP 기본 인증

μ‚¬μš©μž 이름과 λΉ„λ°€λ²ˆν˜Έλ₯Ό Authorization 헀더에 ν¬ν•¨ν•˜μ—¬ μ „λ‹¬ν•˜λŠ” HTTP κΈ°λ³Έ 인증의 κ²½μš°μ—λ„ Base64 인코딩을 μ‚¬μš©ν•©λ‹ˆλ‹€. μ΄λŠ” HTTP ν—€λ”μ˜ 값이 μ•„μŠ€ν‚€ μ½”λ“œλ‘œ μΈμ½”λ”©λ˜μ–΄μ•Όν•˜κΈ° λ•Œλ¬Έμž…λ‹ˆλ‹€. λ”°λΌμ„œ, μ•„μŠ€ν‚€ μ½”λ“œλ‘œ ν‘œν˜„ν•  수 μ—†λŠ” 데이터도 전달할 수 μžˆλ„λ‘ Base64 인코딩을 μ‚¬μš©ν•˜λŠ” κ²ƒμž…λ‹ˆλ‹€.

Authorization: Basic bWFtYm86cGFzc3dvcmQ=

JWT Base64Url

졜근 μ‚¬μš©μž 인증을 μœ„ν•΄ 많이 λ„μž…ν•˜λŠ” JWT(JSON Web Token)λŠ” νŽ˜μ΄λ‘œλ“œμ™€ μ‹œκ·Έλ‹ˆμ²˜ 뢀뢄을 Base64Url(URL Safe Base64) 둜 μΈμ½”λ”©ν•©λ‹ˆλ‹€. JWTλ₯Ό Base64둜 μΈμ½”λ”©ν•˜λŠ” μ΄μœ λŠ” 토큰이 URL νŒŒλΌλ―Έν„°λ‘œ 전솑될 수 있기 λ•Œλ¬Έμž…λ‹ˆλ‹€.

끝마치며

Base64λ₯Ό μ‚¬μš©ν•˜λŠ” μ΄μœ μ— λŒ€ν•΄μ„œ κ°„λ‹¨ν•˜κ²Œ μ•Œμ•„λ³΄μ•˜μŠ΅λ‹ˆλ‹€. 초보 κ°œλ°œμžλΆ„λ“€ 뿐만 μ•„λ‹ˆλΌ μ €μ²˜λŸΌ Base64에 λŒ€ν•΄μ„œ μΈμ§€ν•˜κ³  μžˆμ—ˆλ˜ λΆ„λ“€μ—κ²Œλ„ 도움이 λ˜μ—ˆμœΌλ©΄ ν•©λ‹ˆλ‹€. κ°μ‚¬ν•©λ‹ˆλ‹€.

Base64에 λŒ€ν•΄μ„œ μžμ„Έν•œ λ‚΄μš©μ„ μ•Œκ³  μ‹Άλ‹€λ©΄ RFC4648을 μ°Έκ³ ν•˜μ„Έμš”.