4 def base64_from_hex(_hex):
5 return codecs.encode(codecs.decode(_hex, 'hex'), 'base64').decode('utf-8')
7 class Set1Challenge1Tests(unittest.TestCase):
8 def test_converts_hex_to_base64(self):
9 expected = 'SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t\n'
10 actual = base64_from_hex('49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d')
11 self.assertEqual(expected, actual)
13 if __name__ == '__main__':