From b37c633b0ba51e497920762fa2eb4d732ebca291 Mon Sep 17 00:00:00 2001 From: David Kerkeslager Date: Fri, 12 Feb 2021 13:14:56 -0500 Subject: [PATCH] Move previous cryptopals work into an Erlang subfolder, start cryptopals in Python 3 --- {cryptopals => cryptopals-erlang}/.gitignore | 0 {cryptopals => cryptopals-erlang}/01.01/hex.erl | 0 .../01.01/hex_tests.erl | 0 .../01.01/hex_to_base64.erl | 0 .../01.01/hex_to_base64_tests.erl | 0 {cryptopals => cryptopals-erlang}/01.01/test.sh | 0 {cryptopals => cryptopals-erlang}/01.02/hex.erl | 0 .../01.02/hex_tests.erl | 0 {cryptopals => cryptopals-erlang}/01.02/test.sh | 0 {cryptopals => cryptopals-erlang}/01.03/1984.html | 0 {cryptopals => cryptopals-erlang}/01.03/hex.erl | 0 .../01.03/hex_tests.erl | 0 {cryptopals => cryptopals-erlang}/01.03/main.erl | 0 {cryptopals => cryptopals-erlang}/01.03/run.sh | 0 {cryptopals => cryptopals-erlang}/01.03/stat.erl | 0 .../01.03/stat_tests.erl | 0 {cryptopals => cryptopals-erlang}/01.03/test.sh | 0 cryptopals-python/cryptopals.py | 14 ++++++++++++++ 18 files changed, 14 insertions(+) rename {cryptopals => cryptopals-erlang}/.gitignore (100%) rename {cryptopals => cryptopals-erlang}/01.01/hex.erl (100%) rename {cryptopals => cryptopals-erlang}/01.01/hex_tests.erl (100%) rename {cryptopals => cryptopals-erlang}/01.01/hex_to_base64.erl (100%) rename {cryptopals => cryptopals-erlang}/01.01/hex_to_base64_tests.erl (100%) rename {cryptopals => cryptopals-erlang}/01.01/test.sh (100%) rename {cryptopals => cryptopals-erlang}/01.02/hex.erl (100%) rename {cryptopals => cryptopals-erlang}/01.02/hex_tests.erl (100%) rename {cryptopals => cryptopals-erlang}/01.02/test.sh (100%) rename {cryptopals => cryptopals-erlang}/01.03/1984.html (100%) rename {cryptopals => cryptopals-erlang}/01.03/hex.erl (100%) rename {cryptopals => cryptopals-erlang}/01.03/hex_tests.erl (100%) rename {cryptopals => cryptopals-erlang}/01.03/main.erl (100%) rename {cryptopals => cryptopals-erlang}/01.03/run.sh (100%) rename {cryptopals => cryptopals-erlang}/01.03/stat.erl (100%) rename {cryptopals => cryptopals-erlang}/01.03/stat_tests.erl (100%) rename {cryptopals => cryptopals-erlang}/01.03/test.sh (100%) create mode 100644 cryptopals-python/cryptopals.py diff --git a/cryptopals/.gitignore b/cryptopals-erlang/.gitignore similarity index 100% rename from cryptopals/.gitignore rename to cryptopals-erlang/.gitignore diff --git a/cryptopals/01.01/hex.erl b/cryptopals-erlang/01.01/hex.erl similarity index 100% rename from cryptopals/01.01/hex.erl rename to cryptopals-erlang/01.01/hex.erl diff --git a/cryptopals/01.01/hex_tests.erl b/cryptopals-erlang/01.01/hex_tests.erl similarity index 100% rename from cryptopals/01.01/hex_tests.erl rename to cryptopals-erlang/01.01/hex_tests.erl diff --git a/cryptopals/01.01/hex_to_base64.erl b/cryptopals-erlang/01.01/hex_to_base64.erl similarity index 100% rename from cryptopals/01.01/hex_to_base64.erl rename to cryptopals-erlang/01.01/hex_to_base64.erl diff --git a/cryptopals/01.01/hex_to_base64_tests.erl b/cryptopals-erlang/01.01/hex_to_base64_tests.erl similarity index 100% rename from cryptopals/01.01/hex_to_base64_tests.erl rename to cryptopals-erlang/01.01/hex_to_base64_tests.erl diff --git a/cryptopals/01.01/test.sh b/cryptopals-erlang/01.01/test.sh similarity index 100% rename from cryptopals/01.01/test.sh rename to cryptopals-erlang/01.01/test.sh diff --git a/cryptopals/01.02/hex.erl b/cryptopals-erlang/01.02/hex.erl similarity index 100% rename from cryptopals/01.02/hex.erl rename to cryptopals-erlang/01.02/hex.erl diff --git a/cryptopals/01.02/hex_tests.erl b/cryptopals-erlang/01.02/hex_tests.erl similarity index 100% rename from cryptopals/01.02/hex_tests.erl rename to cryptopals-erlang/01.02/hex_tests.erl diff --git a/cryptopals/01.02/test.sh b/cryptopals-erlang/01.02/test.sh similarity index 100% rename from cryptopals/01.02/test.sh rename to cryptopals-erlang/01.02/test.sh diff --git a/cryptopals/01.03/1984.html b/cryptopals-erlang/01.03/1984.html similarity index 100% rename from cryptopals/01.03/1984.html rename to cryptopals-erlang/01.03/1984.html diff --git a/cryptopals/01.03/hex.erl b/cryptopals-erlang/01.03/hex.erl similarity index 100% rename from cryptopals/01.03/hex.erl rename to cryptopals-erlang/01.03/hex.erl diff --git a/cryptopals/01.03/hex_tests.erl b/cryptopals-erlang/01.03/hex_tests.erl similarity index 100% rename from cryptopals/01.03/hex_tests.erl rename to cryptopals-erlang/01.03/hex_tests.erl diff --git a/cryptopals/01.03/main.erl b/cryptopals-erlang/01.03/main.erl similarity index 100% rename from cryptopals/01.03/main.erl rename to cryptopals-erlang/01.03/main.erl diff --git a/cryptopals/01.03/run.sh b/cryptopals-erlang/01.03/run.sh similarity index 100% rename from cryptopals/01.03/run.sh rename to cryptopals-erlang/01.03/run.sh diff --git a/cryptopals/01.03/stat.erl b/cryptopals-erlang/01.03/stat.erl similarity index 100% rename from cryptopals/01.03/stat.erl rename to cryptopals-erlang/01.03/stat.erl diff --git a/cryptopals/01.03/stat_tests.erl b/cryptopals-erlang/01.03/stat_tests.erl similarity index 100% rename from cryptopals/01.03/stat_tests.erl rename to cryptopals-erlang/01.03/stat_tests.erl diff --git a/cryptopals/01.03/test.sh b/cryptopals-erlang/01.03/test.sh similarity index 100% rename from cryptopals/01.03/test.sh rename to cryptopals-erlang/01.03/test.sh diff --git a/cryptopals-python/cryptopals.py b/cryptopals-python/cryptopals.py new file mode 100644 index 0000000..8752786 --- /dev/null +++ b/cryptopals-python/cryptopals.py @@ -0,0 +1,14 @@ +import codecs +import unittest + +def base64_from_hex(_hex): + return codecs.encode(codecs.decode(_hex, 'hex'), 'base64').decode('utf-8') + +class Set1Challenge1Tests(unittest.TestCase): + def test_converts_hex_to_base64(self): + expected = 'SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t\n' + actual = base64_from_hex('49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d') + self.assertEqual(expected, actual) + +if __name__ == '__main__': + unittest.main() -- 2.20.1