feat(wpcarro/scratch): Upload my solutions to cryptopals

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
This commit is contained in:
William Carroll 2021-12-29 12:11:42 -04:00 committed by clbot
parent 5c0ec720af
commit 4cf86f2e53
6 changed files with 409 additions and 0 deletions

View file

@ -0,0 +1,19 @@
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!")