Base64
Another common encoding scheme is Base64, which allows us to represent binary data as an ASCII string using an alphabet of 64 characters. One character of a Base64 string encodes 6 binary digits (bits), and so 4 characters of Base64 encode three 8-bit bytes.
Base64 is most commonly used online, so binary data such as images can be easily included into HTML or CSS files.
Take the below hex string, decode it into bytes and then encode it into Base64.
72bca9b68fc16ac7beeb8f849dca1d8a783e8acf9679bf9269f7bf
In Python, after importing the base64 module with import base64, you can use the base64.b64encode() function. Remember to decode the hex first as the challenge description states.
또 다른 일반적인 인코딩 방식은 Base64인데, 이것은 이진 데이터를 64자의 알파벳을 사용하여 ASCII 문자열로 표현할 수 있게 해준다. Base64 문자열의 한 문자는 6개의 이진수를 인코딩하고, 따라서 Base64의 4개의 문자는 3개의 8비트 바이트를 인코딩한다.
Base64는 온라인에서 가장 많이 사용되므로 이미지와 같은 바이너리 데이터를 HTML이나 CSS 파일에 쉽게 포함시킬 수 있다.
아래의 16진수 문자열을 사용하여 바이트로 디코딩한 다음 Base64로 인코딩 하여라.
72bca9b68fc16ac7beeb8f849dca1d8a783e8acf9679bf9269f7bf
파이썬에서는 base64를 Import base64로 base64 모듈을 Import 한 후 base64.b64encode() 함수를 사용할 수 있다. 챌린지 설명에 따라 헥스를 먼저 디코딩하는 것을 기억하라.
일단 저 Hex를 바이트로 디코딩 하고 Base64로 인코딩한 것이 flag 인 것 같다.
import base64
a = bytes.fromhex('72bca9b68fc16ac7beeb8f849dca1d8a783e8acf9679bf9269f7bf')
print(base64.b64encode(a))
bytes.fromhex는 입력된 hex 값을 바이트 값으로 바꿔주는 것이고
base64.b64encode는 입력된 값을 base64로 인코딩 해주는 것이다. 이때 꼭 base64 모듈을 import 해줄 것!!!
파이썬으로 돌리면 flag을 얻을 수 있다.
🔑: crypto/Base+64+Encoding+is+Web+Safe/