Skip to main content

Coverage Status Build Status

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)

Typing stubs

The project also includes typed stubs for mypy. These stubs are autogenerated by stubgen, so they may be incomplete. Please let me know if they do not meet your needs and I can manage them manually.

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

MIT

Metadata

Release files for ms-ovba-compression 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ms-ovba-compression 1.0.1
File Size Uploaded Provenance Actions
ms_ovba_compression-1.0.1.tar.gz 10.9 kB Without provenance Details for ms_ovba_compression-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ms-ovba-compression 1.0.1
File Interpreter ABI Platform Actions
ms_ovba_compression-1.0.1-py3-none-any.whl Python 3 none any Details for ms_ovba_compression-1.0.1-py3-none-any.whl

Total release size: 19.8 kB

Release files / ms_ovba_compression-1.0.1.tar.gz

Download URL ms_ovba_compression-1.0.1.tar.gz
Size 10.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a64c072d2ffb4ed5c4332b6ff3cb54987a879410edbc6e8794ddf222d469d13f
BLAKE2b-256 checksum
How to use checksums
4e04d0a30fa1f8122b2d7d6efd6dae7adae0a96d8e37ee0e9b7c02b6971942dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / ms_ovba_compression-1.0.1-py3-none-any.whl

Download URL ms_ovba_compression-1.0.1-py3-none-any.whl
Size 8.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
12881bb1ab3d86c8eb2d30f539cd6bc180cdc4a6b2d8d8e59a678719951ed9ba
BLAKE2b-256 checksum
How to use checksums
42edcd046d444194a8de772c1d1b51c13661864d6b6a10fe77bf72e8792caaf1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Security for ms-ovba-compression 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page