Ejemplo n.º 1
0
class TestBB(unittest.TestCase):

    BB = BubbleBabble()
    CYR_BB = BubbleBabble(
        consonants=u'бгджзклмнпрстфхцч',
        vowels=u'аиоуыэ',
    )

    TESTS = {
        ('', 'xexax'),
        ('abcd', 'ximek-domek-gyxox'),
        ('asdf', 'ximel-finek-koxex'),
        ('0123456789', 'xesaf-casef-fytef-hutif-lovof-nixix'),
        ('Testing a sentence.',
         'xihak-hysul-gapak-venyd-bumud-besek-heryl-gynek-vumuk-hyrox'),
        ('1234567890', 'xesef-disof-gytuf-katof-movif-baxux'),
        ('Pineapple', 'xigak-nyryk-humil-bosek-sonax'),
    }

    NON_ASCII = u'Pchnąć w tę łódź jeża lub ośm skrzyń fig'

    def test_encode(self):
        """Test encoding valid values"""
        for src, encoded in self.TESTS:
            self.assertEqual(self.BB.encode(src), encoded)

    def test_encode_bytes(self):
        """Test encoding valid values converted to bytes"""
        for src, encoded in self.TESTS:
            self.assertEqual(self.BB.encode(src.encode('utf-8')), encoded)

    def test_encode_nonascii(self):
        """Non-ASCII characters should raise errors"""
        with self.assertRaises(ValueError):
            self.BB.encode(self.NON_ASCII)

    def test_encode_utf8(self):
        """Encoding text with UTF-8 should allow to use bubble babble"""
        utf = self.NON_ASCII.encode('utf-8')
        bb = self.BB.encode(utf)
        decoded = self.BB.decode(bb).decode('utf-8')
        self.assertEqual(decoded, self.NON_ASCII)

    def test_decode(self):
        """Test decoding valid values"""
        for src, encoded in self.TESTS:
            self.assertEqual(self.BB.decode(encoded).decode('utf-8'), src)

    def test_encode_cyrillic(self):
        """Encode data with cirillic alphabet"""
        src = b'0123456789'
        encoded = u'читаж-гатиж-жэфиж-кыфож-мухуж-почоч'
        self.assertEqual(
            self.CYR_BB.encode(src),
            encoded,
        )
        self.assertEqual(
            self.CYR_BB.decode(encoded),
            src,
        )
Ejemplo n.º 2
0
Archivo: tool.py Proyecto: 0xchase/ctfs
def bubblebabble(val):
	val = val.strip("\n")
	bb = BubbleBabble()
	try:
		return str(bb.decode(val).decode("utf-8"))
	except Exception as e:
		return None
Ejemplo n.º 3
0
def bb():
    try:
        bb = BubbleBabble()
        bbre = bb.decode(str(src))
        print(" [+] Bubble Babble :      ==  " + str(bbre)[2:-1])
    except:
        bb_str_info = "error"
        print(" [-] Not Bubble Babble . ")
    show_info()
Ejemplo n.º 4
0
def bublble_d(txt):
    from bubblepy import BubbleBabble
    bb = BubbleBabble()
    return bb.decode(txt.decode())
Ejemplo n.º 5
0
from bubblepy import BubbleBabble

bb = BubbleBabble()
message = bb.decode('xipak-comok-repuk-vanik-dytuk-dimyk-sinyx').decode(
    'utf-8')
print(message)
Ejemplo n.º 6
0
from bubblepy import BubbleBabble

bb = BubbleBabble()
with open('flag.enc', 'r') as f:
    print bb.decode(f.read())
Ejemplo n.º 7
0
def decodeBubble(code):
    bb = BubbleBabble()
    return bb.decode(code)
Ejemplo n.º 8
0
def encodeBubble(string):
    bb = BubbleBabble()
    return bb.encode(string)