Move previous cryptopals work into an Erlang subfolder, start cryptopals in Python 3
[sandbox] / cryptopals-python / cryptopals.py
diff --git a/cryptopals-python/cryptopals.py b/cryptopals-python/cryptopals.py
new file mode 100644 (file)
index 0000000..8752786
--- /dev/null
@@ -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()