Skip to main content

Secure Tar

Secure Tarfile library

It's a streaming wrapper around python tarfile and allow secure handling files and support encryption.

from securetar import SecureTarFile, atomic_contents_add
from pathlib import Path

path_to_add = Path(".")

with SecureTarFile("test.tar", "w") as tar_file:
    atomic_contents_add(
        tar_file,
        path_to_add,
        file_filter=lambda _: False,
        arcname=".",
    )

with SecureTarFile("test.tar", "w", b"AES128_KEY_SIZE") as tar_file:
    atomic_contents_add(
        tar_file,
        path_to_add,
        file_filter=lambda _: False,
        arcname=".",
    )

A common pattern is to create an outer uncompressed tarfile that contains a variety of inner tar files. This can be accomplished without writing out multiple files with the following pattern.

from securetar import SecureTarFile, atomic_contents_add
from pathlib import Path

path_1 = Path("path1")
path_2 = Path("path2")

outer_secure_tar_file = SecureTarFile("pkg.tar", "w", gzip=False)

with outer_secure_tar_file as outer_tar_file:
    with outer_secure_tar_file.create_inner_tar(
        "./backup1.tar.gz", gzip=True
    ) as inner_tar_file:
        atomic_contents_add(
            inner_tar_file,
            path_1,
            file_filter=lambda _: False,
            arcname=".",
        )

    with outer_secure_tar_file.create_inner_tar(
        "./backup2.tar.gz", gzip=True
    ) as inner_tar_file:
        atomic_contents_add(
            inner_tar_file,
            path_2,
            file_filter=lambda _: False,
            arcname=".",
        )

Metadata

Release files for securetar 2026.4.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 securetar 2026.4.1
File Size Uploaded
securetar-2026.4.1.tar.gz 28.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for securetar 2026.4.1
File Interpreter ABI Platform
securetar-2026.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 47.6 kB

Release files / securetar-2026.4.1.tar.gz

Download URL securetar-2026.4.1.tar.gz
Size 28.3 kB
Tags Source
SHA-256 checksum
How to use checksums
536108c7cec0bdd6fb51abd8d293deba02930124d76ec5dd4599ae5e0c755638
BLAKE2b-256 checksum
How to use checksums
9054c7084733ce23f33c5f863734d6fd0c1789ba9ec771257cc54529c7a999ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release files / securetar-2026.4.1-py3-none-any.whl

Download URL securetar-2026.4.1-py3-none-any.whl
Size 19.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7cf66c204d678b9d1e2d17814c83048a6468e928ea00edb7e6c1efe72aab0540
BLAKE2b-256 checksum
How to use checksums
fb564ef84868d1ff2f77ac080929117283ac9d18f7d018ae64fa1e7f957a8d20
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3
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