Esempio n. 1
0
    def test_base64_decode(self):
        tools.ok_(base64.b64decode(self.b_byte_encoded) == self.b_byte_chars)
        tools.ok_(base64.b64decode(self.b_byte_encoded_urlsafe, altchars='-_') == self.b_byte_chars)
        tools.ok_(base64.standard_b64decode(self.b_byte_encoded) == self.b_byte_chars)
        tools.ok_(base64.urlsafe_b64decode(self.b_byte_encoded_urlsafe) == self.b_byte_chars)

        tools.ok_(base64.b64decode(self.b_byte_encoded) == self.b_byte_chars)
        tools.ok_(base64.b64decode(self.b_byte_encoded_urlsafe, altchars='-_') == self.b_byte_chars)
        tools.ok_(base64.standard_b64decode(self.b_byte_encoded) == self.b_byte_chars)
        tools.ok_(base64.urlsafe_b64decode(self.b_byte_encoded_urlsafe) == self.b_byte_chars)
Esempio n. 2
0
 def test_b64decode(self):
     eq = self.assertEqual
     eq(base64.b64decode("d3d3LnB5dGhvbi5vcmc="), "www.python.org")
     eq(base64.b64decode('AA=='), '\x00')
     eq(base64.b64decode("YQ=="), "a")
     eq(base64.b64decode("YWI="), "ab")
     eq(base64.b64decode("YWJj"), "abc")
     eq(base64.b64decode("YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNE"
                         "RUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0\nNT"
                         "Y3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ=="),
        "abcdefghijklmnopqrstuvwxyz"
        "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        "0123456789!@#0^&*();:<>,. []{}")
     eq(base64.b64decode(''), '')
     # Test with arbitrary alternative characters
     eq(base64.b64decode('01a*b$cd', altchars='*$'), '\xd3V\xbeo\xf7\x1d')
     # Test standard alphabet
     eq(base64.standard_b64decode("d3d3LnB5dGhvbi5vcmc="), "www.python.org")
     eq(base64.standard_b64decode("YQ=="), "a")
     eq(base64.standard_b64decode("YWI="), "ab")
     eq(base64.standard_b64decode("YWJj"), "abc")
     eq(base64.standard_b64decode(""), "")
     eq(base64.standard_b64decode("YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNE"
                                  "RUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0NT"
                                  "Y3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ=="),
        "abcdefghijklmnopqrstuvwxyz"
        "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        "0123456789!@#0^&*();:<>,. []{}")
     # Test with 'URL safe' alternative characters
     eq(base64.urlsafe_b64decode('01a-b_cd'), '\xd3V\xbeo\xf7\x1d')
Esempio n. 3
0
 def test_b64decode(self):
     eq = self.assertEqual
     eq(base64.b64decode("d3d3LnB5dGhvbi5vcmc="), "www.python.org")
     eq(base64.b64decode('AA=='), '\x00')
     eq(base64.b64decode("YQ=="), "a")
     eq(base64.b64decode("YWI="), "ab")
     eq(base64.b64decode("YWJj"), "abc")
     eq(base64.b64decode("YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNE"
                         "RUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0\nNT"
                         "Y3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ=="),
        "abcdefghijklmnopqrstuvwxyz"
        "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        "0123456789!@#0^&*();:<>,. []{}")
     eq(base64.b64decode(''), '')
     # Test with arbitrary alternative characters
     eq(base64.b64decode('01a*b$cd', altchars='*$'), '\xd3V\xbeo\xf7\x1d')
     # Test standard alphabet
     eq(base64.standard_b64decode("d3d3LnB5dGhvbi5vcmc="), "www.python.org")
     eq(base64.standard_b64decode("YQ=="), "a")
     eq(base64.standard_b64decode("YWI="), "ab")
     eq(base64.standard_b64decode("YWJj"), "abc")
     eq(base64.standard_b64decode(""), "")
     eq(base64.standard_b64decode("YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNE"
                                  "RUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0NT"
                                  "Y3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ=="),
        "abcdefghijklmnopqrstuvwxyz"
        "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        "0123456789!@#0^&*();:<>,. []{}")
     # Test with 'URL safe' alternative characters
     eq(base64.urlsafe_b64decode('01a-b_cd'), '\xd3V\xbeo\xf7\x1d')
Esempio n. 4
0
    def test_base64_decode(self):
        tools.ok_(base64.b64decode(self.b_byte_encoded) == self.b_byte_chars)
        tools.ok_(
            base64.b64decode(self.b_byte_encoded_urlsafe, altchars='-_') ==
            self.b_byte_chars)
        tools.ok_(
            base64.standard_b64decode(self.b_byte_encoded) ==
            self.b_byte_chars)
        tools.ok_(
            base64.urlsafe_b64decode(self.b_byte_encoded_urlsafe) ==
            self.b_byte_chars)

        tools.ok_(base64.b64decode(self.b_byte_encoded) == self.b_byte_chars)
        tools.ok_(
            base64.b64decode(self.b_byte_encoded_urlsafe, altchars='-_') ==
            self.b_byte_chars)
        tools.ok_(
            base64.standard_b64decode(self.b_byte_encoded) ==
            self.b_byte_chars)
        tools.ok_(
            base64.urlsafe_b64decode(self.b_byte_encoded_urlsafe) ==
            self.b_byte_chars)