Пример #1
0
    def test_modified(self):
        """
        Test a changed crypted data
        """
        txt = u"".join([unichr(i) for i in xrange(0, 256)])
        key = u"".join([unichr(i) for i in xrange(256, 0, -1)])
        original_crypted = encrypt(txt, key, use_base64=False)

        for i in xrange(len(original_crypted)):
            if original_crypted[i] == u"\x00":
                wrong_char = u"\x01"
            else:
                wrong_char = u"\x00"

            invalid_crypted = u"".join([
                original_crypted[:i], wrong_char, original_crypted[i+1:]
            ])
            try:
                decrypt(invalid_crypted, key, use_base64=False)
            except SaltHashError:
                # OK
                pass
            else:
                msg = "SaltHashError not raised"
                print "_"*80
                print msg
                print "position:", i
                print "-"*80
                raise AssertionError(msg)
Пример #2
0
 def test_latin1(self):
     """
     Test with the first 256 unicode characerts
     """
     txt = u"".join([unichr(i) for i in xrange(0, 256)])
     key = u"".join([unichr(i) for i in xrange(256, 0, -1)])
     crypted = encrypt(txt, key, use_base64=False)
     decrypted = decrypt(crypted, key, use_base64=False)
     self._assert_tests(txt, key, crypted, decrypted)
Пример #3
0
 def test_unicode(self):
     """
     Test with 10.000 unicode characerts
     """
     txt = u"".join([unichr(i) for i in xrange(0, 65535, 65535 / 9999)])
     key = u"".join([unichr(i) for i in xrange(2, 65535, 65535 / 9999)])
     crypted = encrypt(txt, key, use_base64=False)
     decrypted = decrypt(crypted, key, use_base64=False)
     self._assert_tests(txt, key, crypted, decrypted)