Bubble Babble Binary Data Encoding
Project description
# bubblepy
Bubble Babble Binary Data Encoding - Python library
See http://bohwaz.net/archives/web/Bubble_Babble.html for details.
Original Copyright 2011 BohwaZ - http://bohwaz.net/
Copyleft 2015 europa - https://github.com/eur0pa
Copyright 2016 zefciu - https://github.com/zefciu
Based on :
- Bubble Babble spec: http://wiki.yak.net/589/Bubble_Babble_Encoding.txt
- Nitrxgen PHP script: http://www.nitrxgen.net/bubblebabble.php
- Bubble Babble encoder for Go: http://codereview.appspot.com/181122
- Bubble Babble class for PHP: https://github.com/bohwaz/bubblebabble
Use:
```pyshell
>>> from bubblepy import BubbleBabble
>>>
>>> # Encoding simple ASCII strings
>>> bb = BubbleBabble()
>>> bb.encode('Pineapple')
'xigak-nyryk-humil-bosek-sonax'
>>> bb.decode('xigak-nyryk-humil-bosek-sonax')
b'Pineapple'
>>>
>>> # To encode non-ASCI data you must encode to bytestring
>>> bb.encode('Pchnąć w tę łódź jeża lub ośm skrzyń fig')
Traceback (most recent call last):
(...)
ValueError: Non-ASCII character found. Encode your data
>>> bb.encode('Pchnąć w tę łódź jeża lub ośm skrzyń fig'.encode('utf-8'))
xikik-cocor-subur-fucam-dycem-lymyk-lecyn-nacen-riras-gycud-bepak-cicur-pocym-gyxex
>>> bb.decode('xikik-cocor-subur-fucam-dycem-lymyk-lecyn-nacen-riras-gycud-bepak-cicur-pocym-gyxex').decode('utf-8')
'Zażółć gęślą jaźń'
>>>
>>> # You can use Bubble Babble to encode e.g. uuids
>>> import uuid
>>> u1 = uuid.uuid4()
>>> bb.encode(u1.bytes)
'xezeg-tetor-pybyt-vuboc-gapop-boceg-todup-banyk-voxux'
>>> u2 = uuid.UUID(bytes=bb.decode('xezeg-tetor-pybyt-vuboc-gapop-boceg-todup-banyk-voxux'))
>>> u1 == u2
True
>>>
>>> # The default alphabet can be overridden
>>> # Consonants should be 17-letter long and vowels 6-letter long
>>> bb2 = BubbleBabble(consonants=u'бгджзклмнпрстфхцч', vowels=u'аиоуыэ')
>>> bb2.encode(b'0123456789')
'читаж-гатиж-жэфиж-кыфож-мухуж-почоч'
)
```
Bubble Babble Binary Data Encoding - Python library
See http://bohwaz.net/archives/web/Bubble_Babble.html for details.
Original Copyright 2011 BohwaZ - http://bohwaz.net/
Copyleft 2015 europa - https://github.com/eur0pa
Copyright 2016 zefciu - https://github.com/zefciu
Based on :
- Bubble Babble spec: http://wiki.yak.net/589/Bubble_Babble_Encoding.txt
- Nitrxgen PHP script: http://www.nitrxgen.net/bubblebabble.php
- Bubble Babble encoder for Go: http://codereview.appspot.com/181122
- Bubble Babble class for PHP: https://github.com/bohwaz/bubblebabble
Use:
```pyshell
>>> from bubblepy import BubbleBabble
>>>
>>> # Encoding simple ASCII strings
>>> bb = BubbleBabble()
>>> bb.encode('Pineapple')
'xigak-nyryk-humil-bosek-sonax'
>>> bb.decode('xigak-nyryk-humil-bosek-sonax')
b'Pineapple'
>>>
>>> # To encode non-ASCI data you must encode to bytestring
>>> bb.encode('Pchnąć w tę łódź jeża lub ośm skrzyń fig')
Traceback (most recent call last):
(...)
ValueError: Non-ASCII character found. Encode your data
>>> bb.encode('Pchnąć w tę łódź jeża lub ośm skrzyń fig'.encode('utf-8'))
xikik-cocor-subur-fucam-dycem-lymyk-lecyn-nacen-riras-gycud-bepak-cicur-pocym-gyxex
>>> bb.decode('xikik-cocor-subur-fucam-dycem-lymyk-lecyn-nacen-riras-gycud-bepak-cicur-pocym-gyxex').decode('utf-8')
'Zażółć gęślą jaźń'
>>>
>>> # You can use Bubble Babble to encode e.g. uuids
>>> import uuid
>>> u1 = uuid.uuid4()
>>> bb.encode(u1.bytes)
'xezeg-tetor-pybyt-vuboc-gapop-boceg-todup-banyk-voxux'
>>> u2 = uuid.UUID(bytes=bb.decode('xezeg-tetor-pybyt-vuboc-gapop-boceg-todup-banyk-voxux'))
>>> u1 == u2
True
>>>
>>> # The default alphabet can be overridden
>>> # Consonants should be 17-letter long and vowels 6-letter long
>>> bb2 = BubbleBabble(consonants=u'бгджзклмнпрстфхцч', vowels=u'аиоуыэ')
>>> bb2.encode(b'0123456789')
'читаж-гатиж-жэфиж-кыфож-мухуж-почоч'
)
```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
bubblepy-1.0.zip
(7.1 kB
view details)
bubblepy-1.0.tar.bz2
(3.9 kB
view details)
Built Distribution
File details
Details for the file bubblepy-1.0.zip
.
File metadata
- Download URL: bubblepy-1.0.zip
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2453eeeb103bbcfab35a1b4361484868ed113c93ee6d9f633a4ce6cacaff65d |
|
MD5 | cc483fb2667738c23608816155b8faca |
|
BLAKE2b-256 | 962b66bbb2e347c0eb9c81ee46c791f7d9e1265d905a51326e0fd8348a09179f |
File details
Details for the file bubblepy-1.0.tar.bz2
.
File metadata
- Download URL: bubblepy-1.0.tar.bz2
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 367b8016c15e0186ca7b75a4ce40fdc5bd63e3a821bf2308a4d4d1a0f3f2579e |
|
MD5 | 2e5283dc9da190b4079947432dd6ed5a |
|
BLAKE2b-256 | c3cc440c9b881c955e4bcc57ab42f620572e549dff5de0c3edde333c652cc740 |
File details
Details for the file bubblepy-1.0-py3-none-any.whl
.
File metadata
- Download URL: bubblepy-1.0-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce0fd7a56f3a9030364ae240720121b131b3ce716e8273804b396594f37376e6 |
|
MD5 | ef72e72643855673e3c1d2fc6e0ee7ca |
|
BLAKE2b-256 | 093083bd76cac30343ac36bf922dbe69d944332cf718419af1ec7ae8e8f69e6c |