diff options
author | William Carroll <wpcarro@gmail.com> | 2021-12-29T16·11-0400 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2021-12-29T19·34+0000 |
commit | 4cf86f2e53881e473d881072e55b21179e4dd593 (patch) | |
tree | 0ea98356ffbb3dfe2f4abbd44317b2a5c81d6ea0 /users/wpcarro/scratch/cryptopals/set1/c1.py | |
parent | 5c0ec720afc83761d1afda44e9b6acd30375d898 (diff) |
feat(wpcarro/scratch): Upload my solutions to cryptopals r/3501
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
Diffstat (limited to 'users/wpcarro/scratch/cryptopals/set1/c1.py')
-rw-r--r-- | users/wpcarro/scratch/cryptopals/set1/c1.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/users/wpcarro/scratch/cryptopals/set1/c1.py b/users/wpcarro/scratch/cryptopals/set1/c1.py new file mode 100644 index 000000000000..0dfd6bb6d059 --- /dev/null +++ b/users/wpcarro/scratch/cryptopals/set1/c1.py @@ -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!") |