Compress and decompress Microsoft Office VBA data streams.
Project description
MS-OVBA-Compression
Compress or decompress data streams using the MS-OVBA compression algorithm
Microsoft Office files are zip archives that contain a variety of files that work together. One of these files is vbaProject.bin, a binary OLE container which includes any VBA source code in the project. The VBA sources are compressed using the MS-OVBA compression algorithm.
It's worth noting that the compressed output may differ between this and a Microsoft Office applcation. The way the compression algorithm works, multiple valid compressed byte seqences are able to be decompressed into the same uncompressed stream. This project follows the algorithm documented in the MS-OVBA specification, while one of the test cases has a compressed container that is slightly different than is produced using it's own documented procedure.
Installation
Use the package manager pip to install MS_OVBA_Compression.
pip install ms_ovba_compression
Usage
All inputs and outputs are bytes objects. This library does not operate on files, but on compressed or uncompressed byte streams. Any raw VBA files require a certain amount of normalization before compression. If you are interested in writing or modifying the whole OLE container, refer to Beakerboy/vbaProject-Compiler.
from ms_ovba_compression.ms_ovba import MsOvba
# returns b'\x01\x19°\x00abcdefgh\x00ijklmnop\x00qrstuv.'
input = b'abcdefghijklmnopqrstuv.'
ms_ovba = MsOvba()
ms_ovba.compress(input)
# returns b'#aaabcdefaaaaghijaaaaaklaaamnopqaaaaaaaaaaaarstuvwxyzaaa'
ms_ovba = MsOvba()
compressed = b'\x01/°\x00#aaabcde²f\x00paghij\x018\x08akl\x000mnop\x06q\x02p\x04\x10rstuv\x10wxyz\x00<'
ms_ovba.decompress(compressed)
The objects can be initialized to indicate the endianness if the default little-endian is not desired.
# returns b'\x01°\x19\x00abcdefgh\x00ijklmnop\x00qrstuv.'
input = b'abcdefghijklmnopqrstuv.'
ms_ovba = MsOvba("big")
ms_ovba.compress(input)
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ms_ovba_compression-1.0.0.tar.gz
.
File metadata
- Download URL: ms_ovba_compression-1.0.0.tar.gz
- Upload date:
- Size: 10.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57b48ac615f44c636b5731385b7a99a76c8eb14b91891b4d5fdd8e1be50f8c49 |
|
MD5 | 996aa9eb0ff60e82bd98122120f1d7ca |
|
BLAKE2b-256 | 9fba1f8320f210de30fed114d2e2ce9289683118232ec61bef9c3f5fe43d819e |
File details
Details for the file ms_ovba_compression-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: ms_ovba_compression-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b82361dfda2e8c4660aa5f4c096a81d0eab8103f621cca6c0639a4df12e9a41 |
|
MD5 | 958890afe78b6ffb03739ec208fbad8c |
|
BLAKE2b-256 | fd9caf24849ac3928406bb5d3825130bb9a39d9fccf3aabba98dce27ce73d59b |