kapak


Namekapak JSON
Version 4.0.0rc2 PyPI version JSON
download
home_pagehttps://github.com/amis-shokoohi/kapak
SummaryA simple-to-use file encryption script
upload_time2023-01-26 18:11:36
maintainer
docs_urlNone
authorAmis Shokoohi
requires_python>=3.7,<4.0
licenseApache-2.0
keywords encryption file encryption encrypt file aes aes encryption encryption script
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <p align="center">
  <img src="https://user-images.githubusercontent.com/24605263/214285260-80aed843-17e6-4a2f-98bf-bfb21f900dff.png">
</p>

[![tests](https://github.com/amis-shokoohi/kapak/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/amis-shokoohi/kapak/actions/workflows/test.yml)
[![codecov](https://codecov.io/gh/amis-shokoohi/kapak/branch/main/graph/badge.svg?token=6W2V3QOZKP)](https://codecov.io/gh/amis-shokoohi/kapak)
![GitHub](https://img.shields.io/github/license/amis-shokoohi/kapak)
![GitHub last commit (branch)](https://img.shields.io/github/last-commit/amis-shokoohi/kapak/main)
![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/amis-shokoohi/kapak)
![GitHub Repo stars](https://img.shields.io/github/stars/amis-shokoohi/kapak)
![GitHub forks](https://img.shields.io/github/forks/amis-shokoohi/kapak)

# kapak: A simple-to-use file encryption script

- [Description](#description)
- [Installation](#installation)
- [CLI Usage](#cli-usage)
  - [Encrypt file](#cli-usage-encrypt-file)
  - [Encrypt stdin](#cli-usage-encrypt-stdin)
  - [Password file](#cli-usage-password-file)
- [Integration](#integration)
  - [Encrypt file](#integration-encrypt-file)
  - [Encrypt stdin](#integration-encrypt-stdin)

<span id="description"></span>

## Description

Kapak is a simple-to-use **file encryption** script.<br>
It uses `AES_256_CBC` as its encryption cipher and <br>
`scrypt` key derivation algorithm to generate a 256 bit key.

> If you are wondering what _kapak_ means, it means _mold_.

<span id="installation"></span>

## Installation

```
pip install kapak
```

<span id="cli-usage"></span>

## CLI Usage

```
kapak [global options] [command] [command options] [input]
kapak [encrypt | e] [options] [input]
kapak [decrypt | d] [options] [input]
```

<span id="cli-usage-encrypt-file"></span>

### Encrypt file

```
$ kapak encrypt -o ./image.jpg.kpk ./image.jpg
Enter password:
Confirm password:
■■■■■■■■■■ 100%
```

```
$ kapak decrypt -o ./image.jpg ./image.jpg.kpk
Enter password:
■■■■■■■■■■ 100%
```

<span id="cli-usage-encrypt-stdin"></span>

### Encrypt stdin

```
$ echo 'secret stuff' | kapak encrypt | base64
Enter password:
Confirm password:
AAAAbWth...t/ILJW/v
```

```
$ echo 'AAAAbWth...t/ILJW/v' | base64 --decode | kapak decrypt
Enter password:
secret stuff
```

```
$ cat ./text.txt | kapak encrypt -b 1024 > ./text.txt.kpk
Enter password:
Confirm password:
```

```
$ kapak decrypt -b 1024 ./text.txt.kpk > ./text.txt
Enter password:
```

<span id="cli-usage-password-file"></span>

### Password file

```
$ echo 'P@ssw0rd' > ./password.txt
$ kapak encrypt -p ./password.txt -o ./image.jpg.kpk ./image.jpg
■■■■■■■■■■ 100%
```

```
$ kapak decrypt -p ./password.txt -o ./image.jpg ./image.jpg.kpk
■■■■■■■■■■ 100%
```

<span id="integration"></span>

## Integration

<span id="integration-encrypt-file"></span>

### Encrypt file

```py
from pathlib import Path
from kapak.aes import encrypt

input_file = Path("image.jpg")
output_file = Path("image.jpg.kpk")

with input_file.open("rb") as src, output_file.open("wb") as dst:
    total_len = input_file.stat().st_size
    progress = 0
    for chunk_len in encrypt(src, dst, "P@ssw0rd"):
        progress += chunk_len
        print(f"{progress}/{total_len}")
```

> `kapak.aes.encrypt` is a generator. It yields the length of encrypted data on every iteration.

```py
from pathlib import Path
from itertools import accumulate
from kapak.aes import decrypt

input_file = Path("image.jpg.kpk")
output_file = Path("image.jpg")

with input_file.open("rb") as src, output_file.open("wb") as dst:
    total_len = input_file.stat().st_size
    for progress in accumulate(decrypt(src, dst, "P@ssw0rd")):
        print(f"{progress}/{total_len}")
```

> `kapak.aes.decrypt` is a generator. It yields the length of decrypted data on every iteration.

<span id="integration-encrypt-stdin"></span>

### Encrypt stdin

```py
import io
import sys
import base64
from kapak.aes import encrypt

with io.BytesIO() as dst:
    for _ in encrypt(
        src=sys.stdin.buffer,
        dst=dst,
        password="P@ssw0rd",
        buffer_size=1024
    ):
        pass
    encrypted_data = dst.getvalue()
    encrypted_data_base64 = base64.standard_b64encode(encrypted_data)
    print(encrypted_data_base64.decode("utf-8"))
```


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/amis-shokoohi/kapak",
    "name": "kapak",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7,<4.0",
    "maintainer_email": "",
    "keywords": "encryption,file encryption,encrypt file,aes,aes encryption,encryption script",
    "author": "Amis Shokoohi",
    "author_email": "amisshokoohi@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/c7/0c/63b075806e012aae27c70a7d32027721ef4f08201ac07f72f5df0194dc27/kapak-4.0.0rc2.tar.gz",
    "platform": null,
    "description": "<p align=\"center\">\n  <img src=\"https://user-images.githubusercontent.com/24605263/214285260-80aed843-17e6-4a2f-98bf-bfb21f900dff.png\">\n</p>\n\n[![tests](https://github.com/amis-shokoohi/kapak/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/amis-shokoohi/kapak/actions/workflows/test.yml)\n[![codecov](https://codecov.io/gh/amis-shokoohi/kapak/branch/main/graph/badge.svg?token=6W2V3QOZKP)](https://codecov.io/gh/amis-shokoohi/kapak)\n![GitHub](https://img.shields.io/github/license/amis-shokoohi/kapak)\n![GitHub last commit (branch)](https://img.shields.io/github/last-commit/amis-shokoohi/kapak/main)\n![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/amis-shokoohi/kapak)\n![GitHub Repo stars](https://img.shields.io/github/stars/amis-shokoohi/kapak)\n![GitHub forks](https://img.shields.io/github/forks/amis-shokoohi/kapak)\n\n# kapak: A simple-to-use file encryption script\n\n- [Description](#description)\n- [Installation](#installation)\n- [CLI Usage](#cli-usage)\n  - [Encrypt file](#cli-usage-encrypt-file)\n  - [Encrypt stdin](#cli-usage-encrypt-stdin)\n  - [Password file](#cli-usage-password-file)\n- [Integration](#integration)\n  - [Encrypt file](#integration-encrypt-file)\n  - [Encrypt stdin](#integration-encrypt-stdin)\n\n<span id=\"description\"></span>\n\n## Description\n\nKapak is a simple-to-use **file encryption** script.<br>\nIt uses `AES_256_CBC` as its encryption cipher and <br>\n`scrypt` key derivation algorithm to generate a 256 bit key.\n\n> If you are wondering what _kapak_ means, it means _mold_.\n\n<span id=\"installation\"></span>\n\n## Installation\n\n```\npip install kapak\n```\n\n<span id=\"cli-usage\"></span>\n\n## CLI Usage\n\n```\nkapak [global options] [command] [command options] [input]\nkapak [encrypt | e] [options] [input]\nkapak [decrypt | d] [options] [input]\n```\n\n<span id=\"cli-usage-encrypt-file\"></span>\n\n### Encrypt file\n\n```\n$ kapak encrypt -o ./image.jpg.kpk ./image.jpg\nEnter password:\nConfirm password:\n\u25a0\u25a0\u25a0\u25a0\u25a0\u25a0\u25a0\u25a0\u25a0\u25a0 100%\n```\n\n```\n$ kapak decrypt -o ./image.jpg ./image.jpg.kpk\nEnter password:\n\u25a0\u25a0\u25a0\u25a0\u25a0\u25a0\u25a0\u25a0\u25a0\u25a0 100%\n```\n\n<span id=\"cli-usage-encrypt-stdin\"></span>\n\n### Encrypt stdin\n\n```\n$ echo 'secret stuff' | kapak encrypt | base64\nEnter password:\nConfirm password:\nAAAAbWth...t/ILJW/v\n```\n\n```\n$ echo 'AAAAbWth...t/ILJW/v' | base64 --decode | kapak decrypt\nEnter password:\nsecret stuff\n```\n\n```\n$ cat ./text.txt | kapak encrypt -b 1024 > ./text.txt.kpk\nEnter password:\nConfirm password:\n```\n\n```\n$ kapak decrypt -b 1024 ./text.txt.kpk > ./text.txt\nEnter password:\n```\n\n<span id=\"cli-usage-password-file\"></span>\n\n### Password file\n\n```\n$ echo 'P@ssw0rd' > ./password.txt\n$ kapak encrypt -p ./password.txt -o ./image.jpg.kpk ./image.jpg\n\u25a0\u25a0\u25a0\u25a0\u25a0\u25a0\u25a0\u25a0\u25a0\u25a0 100%\n```\n\n```\n$ kapak decrypt -p ./password.txt -o ./image.jpg ./image.jpg.kpk\n\u25a0\u25a0\u25a0\u25a0\u25a0\u25a0\u25a0\u25a0\u25a0\u25a0 100%\n```\n\n<span id=\"integration\"></span>\n\n## Integration\n\n<span id=\"integration-encrypt-file\"></span>\n\n### Encrypt file\n\n```py\nfrom pathlib import Path\nfrom kapak.aes import encrypt\n\ninput_file = Path(\"image.jpg\")\noutput_file = Path(\"image.jpg.kpk\")\n\nwith input_file.open(\"rb\") as src, output_file.open(\"wb\") as dst:\n    total_len = input_file.stat().st_size\n    progress = 0\n    for chunk_len in encrypt(src, dst, \"P@ssw0rd\"):\n        progress += chunk_len\n        print(f\"{progress}/{total_len}\")\n```\n\n> `kapak.aes.encrypt` is a generator. It yields the length of encrypted data on every iteration.\n\n```py\nfrom pathlib import Path\nfrom itertools import accumulate\nfrom kapak.aes import decrypt\n\ninput_file = Path(\"image.jpg.kpk\")\noutput_file = Path(\"image.jpg\")\n\nwith input_file.open(\"rb\") as src, output_file.open(\"wb\") as dst:\n    total_len = input_file.stat().st_size\n    for progress in accumulate(decrypt(src, dst, \"P@ssw0rd\")):\n        print(f\"{progress}/{total_len}\")\n```\n\n> `kapak.aes.decrypt` is a generator. It yields the length of decrypted data on every iteration.\n\n<span id=\"integration-encrypt-stdin\"></span>\n\n### Encrypt stdin\n\n```py\nimport io\nimport sys\nimport base64\nfrom kapak.aes import encrypt\n\nwith io.BytesIO() as dst:\n    for _ in encrypt(\n        src=sys.stdin.buffer,\n        dst=dst,\n        password=\"P@ssw0rd\",\n        buffer_size=1024\n    ):\n        pass\n    encrypted_data = dst.getvalue()\n    encrypted_data_base64 = base64.standard_b64encode(encrypted_data)\n    print(encrypted_data_base64.decode(\"utf-8\"))\n```\n\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "A simple-to-use file encryption script",
    "version": "4.0.0rc2",
    "split_keywords": [
        "encryption",
        "file encryption",
        "encrypt file",
        "aes",
        "aes encryption",
        "encryption script"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b737081af5d584618be71674404f37223697a222de986c3d61f977403b73e0cc",
                "md5": "73a64a6867cfe732442d4fe633c1a872",
                "sha256": "aa87509af085330ee075aa5e99215225e8254cb78c3030c93440c23268d0a21d"
            },
            "downloads": -1,
            "filename": "kapak-4.0.0rc2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "73a64a6867cfe732442d4fe633c1a872",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7,<4.0",
            "size": 13351,
            "upload_time": "2023-01-26T18:11:34",
            "upload_time_iso_8601": "2023-01-26T18:11:34.704123Z",
            "url": "https://files.pythonhosted.org/packages/b7/37/081af5d584618be71674404f37223697a222de986c3d61f977403b73e0cc/kapak-4.0.0rc2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c70c63b075806e012aae27c70a7d32027721ef4f08201ac07f72f5df0194dc27",
                "md5": "d600cb58e55e0e2ad620a0052317fc82",
                "sha256": "f773722978e52003a45ff2794b5728dcb3997907a65ec50b96c29d2c28b772c2"
            },
            "downloads": -1,
            "filename": "kapak-4.0.0rc2.tar.gz",
            "has_sig": false,
            "md5_digest": "d600cb58e55e0e2ad620a0052317fc82",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7,<4.0",
            "size": 12439,
            "upload_time": "2023-01-26T18:11:36",
            "upload_time_iso_8601": "2023-01-26T18:11:36.658562Z",
            "url": "https://files.pythonhosted.org/packages/c7/0c/63b075806e012aae27c70a7d32027721ef4f08201ac07f72f5df0194dc27/kapak-4.0.0rc2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-26 18:11:36",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "amis-shokoohi",
    "github_project": "kapak",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "kapak"
}
        
Elapsed time: 0.03442s