Metadata-Version: 2.4
Name: jzip
Version: 1.1.0
Summary: Utilities to work with gzip compressed base64 content.
Author-email: Jilani Shaik <iammrj.java@gmail.com>
License: MIT License
        
        Copyright (c) 2020 Iam Mr J
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Project-URL: Homepage, https://github.com/iammrj/JZip
Project-URL: Repository, https://github.com/iammrj/JZip
Keywords: gzip,base64,compression,encoding
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENCE
Dynamic: license-file

# JZip

[![CI](https://github.com/iammrj/JZip/actions/workflows/ci.yml/badge.svg)](https://github.com/iammrj/JZip/actions/workflows/ci.yml)
[![Publish to PyPI](https://github.com/iammrj/JZip/actions/workflows/publish.yml/badge.svg)](https://github.com/iammrj/JZip/actions/workflows/publish.yml)
[![PyPI version](https://img.shields.io/pypi/v/jzip.svg)](https://pypi.org/project/jzip/)

Utilities to work with gzip-compressed base64 content.

## Features

- Decode `gzip(base64)` to raw bytes
- Decode `gzip(base64)` to plain text
- Convert `gzip(base64)` to plain base64
- Compress any file (text or binary) into `gzip(base64)`
- Restore original files from `gzip(base64)` safely
- CLI support: `jzip encode` and `jzip decode`
- Strict validation with clear errors for invalid base64/gzip input

## Installation

```bash
pip install jzip
```

## Usage

### Compress file to gzip base64

```python
from jzip import compress_file_to_base64

gzip_b64 = compress_file_to_base64("sample.pdf")
print(gzip_b64)
```

### Restore original file from gzip base64

```python
from jzip import write_to_original_file

write_to_original_file(gzip_b64, "sample.pdf")
```

### Decode gzip base64 to bytes/text/plain base64

```python
from jzip import (
    decode_gzip_base64_to_bytes,
    decode_gzip_base64_to_text,
    decode_gzip_base64_to_plain_base64,
)

raw_bytes = decode_gzip_base64_to_bytes(gzip_b64)
text = decode_gzip_base64_to_text(gzip_b64, encoding="utf-8")
plain_b64 = decode_gzip_base64_to_plain_base64(gzip_b64)
```

## CLI

### Encode a file

```bash
jzip encode ./sample.pdf > sample.gzip.b64
```

### Decode from an argument

```bash
jzip decode ./restored.pdf --input "$(cat sample.gzip.b64)"
```

### Decode from stdin

```bash
cat sample.gzip.b64 | jzip decode ./restored.pdf
```

### Decode from a file containing base64

```bash
jzip decode ./restored.pdf --input-file ./sample.gzip.b64
```

## Automated Release

Pushes to `main` trigger:

- tests
- package build
- publish to PyPI (`skip-existing` enabled)

Configure GitHub secret `PYPI_API_TOKEN` in repository settings for publishing.
