4cf86f2e53
More beginner problems/solutions for CTF-style challenges. Change-Id: Ide229e99e3ccc1ede5a5ca1c2ad039498e49ea4c Reviewed-on: https://cl.tvl.fyi/c/depot/+/4740 Reviewed-by: wpcarro <wpcarro@gmail.com> Autosubmit: wpcarro <wpcarro@gmail.com> Tested-by: BuildkiteCI
19 lines
650 B
Python
19 lines
650 B
Python
from base64 import b64encode
|
|
|
|
################################################################################
|
|
# Challenge 1
|
|
################################################################################
|
|
|
|
def hex_to_base64(x):
|
|
parsed = bytearray.fromhex(x)
|
|
print(parsed.decode()) # easter egg
|
|
return b64encode(parsed).decode()
|
|
|
|
run_tests = False
|
|
if run_tests:
|
|
actual = hex_to_base64("49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d")
|
|
expect = "SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t"
|
|
|
|
print(actual)
|
|
assert actual == expect
|
|
print("Success!")
|