ciph 0.0.0__tar.gz → 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ciph-0.1.0/LICENSE +17 -0
- ciph-0.1.0/MANIFEST.in +6 -0
- ciph-0.1.0/Makefile +11 -0
- ciph-0.1.0/PKG-INFO +235 -0
- ciph-0.1.0/README.md +208 -0
- ciph-0.1.0/ciph/__init__.py +1 -0
- ciph-0.1.0/ciph/cli.py +118 -0
- ciph-0.1.0/ciph.c +241 -0
- ciph-0.1.0/ciph.egg-info/PKG-INFO +235 -0
- ciph-0.1.0/ciph.egg-info/SOURCES.txt +16 -0
- ciph-0.1.0/ciph.egg-info/entry_points.txt +2 -0
- ciph-0.1.0/ciph.egg-info/requires.txt +1 -0
- ciph-0.1.0/ciph.h +36 -0
- ciph-0.1.0/pyproject.toml +45 -0
- ciph-0.1.0/setup.py +17 -0
- ciph-0.0.0/PKG-INFO +0 -15
- ciph-0.0.0/ciph/__init__.py +0 -1
- ciph-0.0.0/ciph.egg-info/PKG-INFO +0 -15
- ciph-0.0.0/ciph.egg-info/SOURCES.txt +0 -6
- ciph-0.0.0/pyproject.toml +0 -27
- {ciph-0.0.0 → ciph-0.1.0}/ciph.egg-info/dependency_links.txt +0 -0
- {ciph-0.0.0 → ciph-0.1.0}/ciph.egg-info/top_level.txt +0 -0
- {ciph-0.0.0 → ciph-0.1.0}/setup.cfg +0 -0
ciph-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
Copyright 2026 Ankit Chaubey
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License.
|
|
9
|
+
You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
See the License for the specific language governing permissions and
|
|
17
|
+
limitations under the License.
|
ciph-0.1.0/MANIFEST.in
ADDED
ciph-0.1.0/Makefile
ADDED
ciph-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ciph
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Fast, streaming file encryption for large media files and cloud uploads
|
|
5
|
+
Author-email: Ankit Chaubey <m.ankitchaubey@gmail.com>
|
|
6
|
+
License: Apache License 2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/ankit-chaubey/ciph
|
|
8
|
+
Project-URL: Source, https://github.com/ankit-chaubey/ciph
|
|
9
|
+
Project-URL: Issues, https://github.com/ankit-chaubey/ciph/issues
|
|
10
|
+
Keywords: encryption,cryptography,security,aes,chacha20,argon2,streaming,files,privacy
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Topic :: Security :: Cryptography
|
|
14
|
+
Classifier: Topic :: System :: Archiving :: Backup
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: Programming Language :: C
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
19
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
20
|
+
Classifier: Operating System :: Unix
|
|
21
|
+
Requires-Python: >=3.8
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: tqdm>=4.60.0
|
|
25
|
+
Dynamic: license-file
|
|
26
|
+
Dynamic: requires-python
|
|
27
|
+
|
|
28
|
+
# ciph
|
|
29
|
+
|
|
30
|
+
**ciph** is a fast, streaming file‑encryption tool built for **large media files** and **cloud uploads**. It uses modern, industry‑standard cryptography and is designed to safely encrypt files **larger than your system RAM**.
|
|
31
|
+
|
|
32
|
+
> Encrypt locally. Upload anywhere. Decrypt only when you trust the environment.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## ❓ Why ciph?
|
|
37
|
+
|
|
38
|
+
Most encryption tools load the entire file into memory before encrypting it. **ciph streams data in fixed-size chunks**, which means you can encrypt a **50 GB 4K video on a machine with only 2 GB of RAM**—smoothly and safely.
|
|
39
|
+
|
|
40
|
+
## ✨ Features
|
|
41
|
+
|
|
42
|
+
* 🔐 **Strong encryption** — AES‑256‑GCM or ChaCha20‑Poly1305
|
|
43
|
+
* 🔑 **Password protection** — Argon2id (memory‑hard key derivation)
|
|
44
|
+
* 🚀 **High performance** — streaming C core (1 MB chunks)
|
|
45
|
+
* 🧠 **Constant memory usage** — works with 10 GB+ files
|
|
46
|
+
* ⚙️ **Hardware‑aware** — AES‑NI when available, ChaCha fallback
|
|
47
|
+
* 🧪 **Integrity protected** — AEAD authentication on every chunk
|
|
48
|
+
* ☁️ **Cloud / Telegram safe** — encrypt before upload
|
|
49
|
+
* 🏷️ **Filename preserved** — original filename & extension are stored and restored on decryption
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## 🔐 Cryptographic Design
|
|
54
|
+
|
|
55
|
+
`ciph` uses a **hybrid (envelope) encryption model**, similar to what is used in modern secure storage systems:
|
|
56
|
+
|
|
57
|
+
1. A random **data key** encrypts the file in streaming mode.
|
|
58
|
+
2. Your password is hardened using **Argon2id**.
|
|
59
|
+
3. The data key is encrypted using the derived password key.
|
|
60
|
+
4. Every chunk is authenticated to detect tampering.
|
|
61
|
+
|
|
62
|
+
No custom crypto. No weak primitives.
|
|
63
|
+
|
|
64
|
+
5. The **original filename (without path)** is stored as encrypted metadata and automatically restored on decryption.
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## 🔒 Security Strength
|
|
69
|
+
|
|
70
|
+
| Component | Algorithm | Strength |
|
|
71
|
+
| -------------------------- | ---------------------------------------- | ------------ |
|
|
72
|
+
| File encryption | AES‑256‑GCM | 256‑bit |
|
|
73
|
+
| File encryption (fallback) | ChaCha20‑Poly1305 | 256‑bit |
|
|
74
|
+
| Password KDF | Argon2id | Memory‑hard |
|
|
75
|
+
| Integrity | AEAD | Tamper‑proof |
|
|
76
|
+
| Nonces | Key-derived per chunk (unique, no reuse) | No reuse |
|
|
77
|
+
|
|
78
|
+
### What this means
|
|
79
|
+
|
|
80
|
+
* Brute‑force attacks are **computationally infeasible**
|
|
81
|
+
* File corruption or tampering is **always detected**
|
|
82
|
+
* Encrypted files are safe on **any cloud platform**
|
|
83
|
+
* Losing the password means **data is unrecoverable**
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## 🚀 Quick Start (Build from Source)
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
git clone https://github.com/ankit-chaubey/ciph
|
|
91
|
+
cd ciph
|
|
92
|
+
make
|
|
93
|
+
pip install .
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## 📦 Installation
|
|
97
|
+
|
|
98
|
+
### Requirements
|
|
99
|
+
|
|
100
|
+
* Linux / Termux
|
|
101
|
+
* Python ≥ 3.8
|
|
102
|
+
* libsodium
|
|
103
|
+
|
|
104
|
+
### Install from PyPI
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
pip install ciph
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## 🚀 Usage
|
|
113
|
+
|
|
114
|
+
### Encrypt a file
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
ciph encrypt video.mp4
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Output:
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
video.mp4.ciph
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Decrypt a file
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
ciph decrypt video.mp4.ciph
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Output:
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
video.mp4
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
> The original filename and extension are automatically restored, even if the encrypted file was renamed.`
|
|
139
|
+
|
|
140
|
+
### Example workflow (Cloud / Telegram)
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
ciph encrypt movie.mkv
|
|
144
|
+
# upload movie.mkv.ciph anywhere
|
|
145
|
+
# share the password securely
|
|
146
|
+
|
|
147
|
+
ciph decrypt movie.mkv.ciph
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## 📝 File Format (V2)
|
|
153
|
+
|
|
154
|
+
| Offset | Size | Description |
|
|
155
|
+
| ------ | ---- | -------------------------------------- |
|
|
156
|
+
| 0 | 4 | Magic bytes (`CIPH`) |
|
|
157
|
+
| 4 | 1 | Format version |
|
|
158
|
+
| 5 | 1 | Cipher mode (1 = AES, 2 = ChaCha) |
|
|
159
|
+
| 6 | 16 | Argon2 salt |
|
|
160
|
+
| 22 | 12 | Key nonce |
|
|
161
|
+
| 34 | 1 | Filename length (N) |
|
|
162
|
+
| 35 | N | Original filename (UTF‑8) |
|
|
163
|
+
| 35+N | 2 | Encrypted data‑key length |
|
|
164
|
+
| … | … | Encrypted data key + encrypted payload |
|
|
165
|
+
|
|
166
|
+
## 📊 Performance
|
|
167
|
+
|
|
168
|
+
* Processes data in **1 MB chunks**
|
|
169
|
+
* Cryptography handled in **C (libsodium)**
|
|
170
|
+
* Python used only for CLI orchestration
|
|
171
|
+
* Typical throughput: **hundreds of MB/s** (CPU‑bound)
|
|
172
|
+
|
|
173
|
+
Encryption is usually faster than your internet upload speed.
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## ⚠️ Limitations (v0.1.0)
|
|
178
|
+
|
|
179
|
+
* Linux / Termux only
|
|
180
|
+
* No resume support yet
|
|
181
|
+
* Progress bar shows start → finish (stream handled in C)
|
|
182
|
+
* Password‑based encryption only (public‑key mode planned)
|
|
183
|
+
* Filename metadata is visible (content remains fully encrypted)
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## 🧑💻 Author & Project
|
|
188
|
+
|
|
189
|
+
**ciph** is **designed, developed, and maintained** by
|
|
190
|
+
|
|
191
|
+
[**Ankit Chaubey (@ankit‑chaubey)**](https://github.com/ankit-chaubey)
|
|
192
|
+
|
|
193
|
+
GitHub Repository:
|
|
194
|
+
👉 **[https://github.com/ankit-chaubey/ciph](https://github.com/ankit-chaubey/ciph)**
|
|
195
|
+
|
|
196
|
+
The project focuses on building **secure, efficient, and practical cryptographic tools** for real‑world usage, especially for media files and cloud storage.
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## 📜 License
|
|
201
|
+
|
|
202
|
+
Apache License 2.0
|
|
203
|
+
|
|
204
|
+
Copyright © 2026 Ankit Chaubey
|
|
205
|
+
|
|
206
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
|
|
207
|
+
You may obtain a copy of the License at:
|
|
208
|
+
|
|
209
|
+
[https://www.apache.org/licenses/LICENSE-2.0](https://www.apache.org/licenses/LICENSE-2.0)
|
|
210
|
+
|
|
211
|
+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,
|
|
212
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
213
|
+
See the License for the specific language governing permissions and limitations under the License.
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
## 🔮 Roadmap
|
|
218
|
+
|
|
219
|
+
Planned future improvements:
|
|
220
|
+
|
|
221
|
+
* Parallel chunk encryption
|
|
222
|
+
* Resume / partial decryption
|
|
223
|
+
* Public‑key encryption mode
|
|
224
|
+
* Real‑time progress callbacks
|
|
225
|
+
* Prebuilt wheels (manylinux)
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## ⚠️ Disclaimer
|
|
230
|
+
|
|
231
|
+
This tool uses strong cryptography.
|
|
232
|
+
|
|
233
|
+
If you forget your password, **your data cannot be recovered**.
|
|
234
|
+
|
|
235
|
+
Use responsibly.
|
ciph-0.1.0/README.md
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
# ciph
|
|
2
|
+
|
|
3
|
+
**ciph** is a fast, streaming file‑encryption tool built for **large media files** and **cloud uploads**. It uses modern, industry‑standard cryptography and is designed to safely encrypt files **larger than your system RAM**.
|
|
4
|
+
|
|
5
|
+
> Encrypt locally. Upload anywhere. Decrypt only when you trust the environment.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## ❓ Why ciph?
|
|
10
|
+
|
|
11
|
+
Most encryption tools load the entire file into memory before encrypting it. **ciph streams data in fixed-size chunks**, which means you can encrypt a **50 GB 4K video on a machine with only 2 GB of RAM**—smoothly and safely.
|
|
12
|
+
|
|
13
|
+
## ✨ Features
|
|
14
|
+
|
|
15
|
+
* 🔐 **Strong encryption** — AES‑256‑GCM or ChaCha20‑Poly1305
|
|
16
|
+
* 🔑 **Password protection** — Argon2id (memory‑hard key derivation)
|
|
17
|
+
* 🚀 **High performance** — streaming C core (1 MB chunks)
|
|
18
|
+
* 🧠 **Constant memory usage** — works with 10 GB+ files
|
|
19
|
+
* ⚙️ **Hardware‑aware** — AES‑NI when available, ChaCha fallback
|
|
20
|
+
* 🧪 **Integrity protected** — AEAD authentication on every chunk
|
|
21
|
+
* ☁️ **Cloud / Telegram safe** — encrypt before upload
|
|
22
|
+
* 🏷️ **Filename preserved** — original filename & extension are stored and restored on decryption
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## 🔐 Cryptographic Design
|
|
27
|
+
|
|
28
|
+
`ciph` uses a **hybrid (envelope) encryption model**, similar to what is used in modern secure storage systems:
|
|
29
|
+
|
|
30
|
+
1. A random **data key** encrypts the file in streaming mode.
|
|
31
|
+
2. Your password is hardened using **Argon2id**.
|
|
32
|
+
3. The data key is encrypted using the derived password key.
|
|
33
|
+
4. Every chunk is authenticated to detect tampering.
|
|
34
|
+
|
|
35
|
+
No custom crypto. No weak primitives.
|
|
36
|
+
|
|
37
|
+
5. The **original filename (without path)** is stored as encrypted metadata and automatically restored on decryption.
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## 🔒 Security Strength
|
|
42
|
+
|
|
43
|
+
| Component | Algorithm | Strength |
|
|
44
|
+
| -------------------------- | ---------------------------------------- | ------------ |
|
|
45
|
+
| File encryption | AES‑256‑GCM | 256‑bit |
|
|
46
|
+
| File encryption (fallback) | ChaCha20‑Poly1305 | 256‑bit |
|
|
47
|
+
| Password KDF | Argon2id | Memory‑hard |
|
|
48
|
+
| Integrity | AEAD | Tamper‑proof |
|
|
49
|
+
| Nonces | Key-derived per chunk (unique, no reuse) | No reuse |
|
|
50
|
+
|
|
51
|
+
### What this means
|
|
52
|
+
|
|
53
|
+
* Brute‑force attacks are **computationally infeasible**
|
|
54
|
+
* File corruption or tampering is **always detected**
|
|
55
|
+
* Encrypted files are safe on **any cloud platform**
|
|
56
|
+
* Losing the password means **data is unrecoverable**
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## 🚀 Quick Start (Build from Source)
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
git clone https://github.com/ankit-chaubey/ciph
|
|
64
|
+
cd ciph
|
|
65
|
+
make
|
|
66
|
+
pip install .
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## 📦 Installation
|
|
70
|
+
|
|
71
|
+
### Requirements
|
|
72
|
+
|
|
73
|
+
* Linux / Termux
|
|
74
|
+
* Python ≥ 3.8
|
|
75
|
+
* libsodium
|
|
76
|
+
|
|
77
|
+
### Install from PyPI
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
pip install ciph
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## 🚀 Usage
|
|
86
|
+
|
|
87
|
+
### Encrypt a file
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
ciph encrypt video.mp4
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Output:
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
video.mp4.ciph
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Decrypt a file
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
ciph decrypt video.mp4.ciph
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Output:
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
video.mp4
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
> The original filename and extension are automatically restored, even if the encrypted file was renamed.`
|
|
112
|
+
|
|
113
|
+
### Example workflow (Cloud / Telegram)
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
ciph encrypt movie.mkv
|
|
117
|
+
# upload movie.mkv.ciph anywhere
|
|
118
|
+
# share the password securely
|
|
119
|
+
|
|
120
|
+
ciph decrypt movie.mkv.ciph
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## 📝 File Format (V2)
|
|
126
|
+
|
|
127
|
+
| Offset | Size | Description |
|
|
128
|
+
| ------ | ---- | -------------------------------------- |
|
|
129
|
+
| 0 | 4 | Magic bytes (`CIPH`) |
|
|
130
|
+
| 4 | 1 | Format version |
|
|
131
|
+
| 5 | 1 | Cipher mode (1 = AES, 2 = ChaCha) |
|
|
132
|
+
| 6 | 16 | Argon2 salt |
|
|
133
|
+
| 22 | 12 | Key nonce |
|
|
134
|
+
| 34 | 1 | Filename length (N) |
|
|
135
|
+
| 35 | N | Original filename (UTF‑8) |
|
|
136
|
+
| 35+N | 2 | Encrypted data‑key length |
|
|
137
|
+
| … | … | Encrypted data key + encrypted payload |
|
|
138
|
+
|
|
139
|
+
## 📊 Performance
|
|
140
|
+
|
|
141
|
+
* Processes data in **1 MB chunks**
|
|
142
|
+
* Cryptography handled in **C (libsodium)**
|
|
143
|
+
* Python used only for CLI orchestration
|
|
144
|
+
* Typical throughput: **hundreds of MB/s** (CPU‑bound)
|
|
145
|
+
|
|
146
|
+
Encryption is usually faster than your internet upload speed.
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## ⚠️ Limitations (v0.1.0)
|
|
151
|
+
|
|
152
|
+
* Linux / Termux only
|
|
153
|
+
* No resume support yet
|
|
154
|
+
* Progress bar shows start → finish (stream handled in C)
|
|
155
|
+
* Password‑based encryption only (public‑key mode planned)
|
|
156
|
+
* Filename metadata is visible (content remains fully encrypted)
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## 🧑💻 Author & Project
|
|
161
|
+
|
|
162
|
+
**ciph** is **designed, developed, and maintained** by
|
|
163
|
+
|
|
164
|
+
[**Ankit Chaubey (@ankit‑chaubey)**](https://github.com/ankit-chaubey)
|
|
165
|
+
|
|
166
|
+
GitHub Repository:
|
|
167
|
+
👉 **[https://github.com/ankit-chaubey/ciph](https://github.com/ankit-chaubey/ciph)**
|
|
168
|
+
|
|
169
|
+
The project focuses on building **secure, efficient, and practical cryptographic tools** for real‑world usage, especially for media files and cloud storage.
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## 📜 License
|
|
174
|
+
|
|
175
|
+
Apache License 2.0
|
|
176
|
+
|
|
177
|
+
Copyright © 2026 Ankit Chaubey
|
|
178
|
+
|
|
179
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
|
|
180
|
+
You may obtain a copy of the License at:
|
|
181
|
+
|
|
182
|
+
[https://www.apache.org/licenses/LICENSE-2.0](https://www.apache.org/licenses/LICENSE-2.0)
|
|
183
|
+
|
|
184
|
+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,
|
|
185
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
186
|
+
See the License for the specific language governing permissions and limitations under the License.
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## 🔮 Roadmap
|
|
191
|
+
|
|
192
|
+
Planned future improvements:
|
|
193
|
+
|
|
194
|
+
* Parallel chunk encryption
|
|
195
|
+
* Resume / partial decryption
|
|
196
|
+
* Public‑key encryption mode
|
|
197
|
+
* Real‑time progress callbacks
|
|
198
|
+
* Prebuilt wheels (manylinux)
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
## ⚠️ Disclaimer
|
|
203
|
+
|
|
204
|
+
This tool uses strong cryptography.
|
|
205
|
+
|
|
206
|
+
If you forget your password, **your data cannot be recovered**.
|
|
207
|
+
|
|
208
|
+
Use responsibly.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.0"
|
ciph-0.1.0/ciph/cli.py
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
import sys, os, getpass, ctypes
|
|
3
|
+
from tqdm import tqdm
|
|
4
|
+
|
|
5
|
+
HERE = os.path.dirname(__file__)
|
|
6
|
+
LIB = ctypes.CDLL(os.path.join(HERE, "_native", "libciph.so"))
|
|
7
|
+
|
|
8
|
+
LIB.ciph_encrypt_stream.argtypes = [
|
|
9
|
+
ctypes.c_void_p, ctypes.c_void_p,
|
|
10
|
+
ctypes.c_char_p, ctypes.c_int,
|
|
11
|
+
ctypes.c_char_p
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
LIB.ciph_decrypt_stream.argtypes = [
|
|
15
|
+
ctypes.c_void_p, ctypes.c_void_p,
|
|
16
|
+
ctypes.c_char_p,
|
|
17
|
+
ctypes.c_char_p, ctypes.c_size_t
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
libc = ctypes.CDLL(None)
|
|
21
|
+
fdopen = libc.fdopen
|
|
22
|
+
fdopen.argtypes = [ctypes.c_int, ctypes.c_char_p]
|
|
23
|
+
fdopen.restype = ctypes.c_void_p
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def detect_cipher():
|
|
27
|
+
try:
|
|
28
|
+
with open("/proc/cpuinfo") as f:
|
|
29
|
+
if "aes" in f.read().lower():
|
|
30
|
+
return 1
|
|
31
|
+
except Exception:
|
|
32
|
+
pass
|
|
33
|
+
return 2
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def get_password():
|
|
37
|
+
pwd = os.getenv("CIPH_PASSWORD")
|
|
38
|
+
if not pwd:
|
|
39
|
+
pwd = getpass.getpass("Password: ")
|
|
40
|
+
return pwd.encode()
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def c_file(py_file, mode):
|
|
44
|
+
fd = os.dup(py_file.fileno()) # 🔑 duplicate FD
|
|
45
|
+
return fdopen(fd, mode)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def main():
|
|
49
|
+
if len(sys.argv) < 3:
|
|
50
|
+
print("usage: ciph encrypt|decrypt <file>")
|
|
51
|
+
sys.exit(1)
|
|
52
|
+
|
|
53
|
+
cmd, src = sys.argv[1], sys.argv[2]
|
|
54
|
+
password = get_password()
|
|
55
|
+
total_size = os.path.getsize(src)
|
|
56
|
+
|
|
57
|
+
fin_py = open(src, "rb")
|
|
58
|
+
fin = c_file(fin_py, b"rb")
|
|
59
|
+
|
|
60
|
+
name_buf = ctypes.create_string_buffer(256)
|
|
61
|
+
|
|
62
|
+
with tqdm(
|
|
63
|
+
total=total_size,
|
|
64
|
+
unit="B",
|
|
65
|
+
unit_scale=True,
|
|
66
|
+
desc=cmd.capitalize()
|
|
67
|
+
) as bar:
|
|
68
|
+
|
|
69
|
+
if cmd == "encrypt":
|
|
70
|
+
out_name = src + ".ciph"
|
|
71
|
+
fout_py = open(out_name, "wb")
|
|
72
|
+
fout = c_file(fout_py, b"wb")
|
|
73
|
+
|
|
74
|
+
LIB.ciph_encrypt_stream(
|
|
75
|
+
fin,
|
|
76
|
+
fout,
|
|
77
|
+
password,
|
|
78
|
+
detect_cipher(),
|
|
79
|
+
os.path.basename(src).encode()
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
bar.update(total_size)
|
|
83
|
+
|
|
84
|
+
elif cmd == "decrypt":
|
|
85
|
+
tmp_name = ".__tmp__"
|
|
86
|
+
fout_py = open(tmp_name, "wb")
|
|
87
|
+
fout = c_file(fout_py, b"wb")
|
|
88
|
+
|
|
89
|
+
res = LIB.ciph_decrypt_stream(
|
|
90
|
+
fin,
|
|
91
|
+
fout,
|
|
92
|
+
password,
|
|
93
|
+
name_buf,
|
|
94
|
+
ctypes.sizeof(name_buf)
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
fout_py.close()
|
|
98
|
+
|
|
99
|
+
if res != 0:
|
|
100
|
+
os.remove(tmp_name)
|
|
101
|
+
print("ciph: wrong password or corrupted file", file=sys.stderr)
|
|
102
|
+
sys.exit(1)
|
|
103
|
+
|
|
104
|
+
out_name = name_buf.value.decode() or "output.dec"
|
|
105
|
+
os.rename(tmp_name, out_name)
|
|
106
|
+
|
|
107
|
+
bar.update(total_size)
|
|
108
|
+
|
|
109
|
+
else:
|
|
110
|
+
print("usage: ciph encrypt|decrypt <file>")
|
|
111
|
+
sys.exit(1)
|
|
112
|
+
|
|
113
|
+
fin_py.close()
|
|
114
|
+
print(f"[+] Output → {out_name}")
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
if __name__ == "__main__":
|
|
118
|
+
main()
|
ciph-0.1.0/ciph.c
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* ciph
|
|
3
|
+
* © 2026 Ankit Chaubey (@ankit-chaubey)
|
|
4
|
+
* https://github.com/ankit-chaubey/ciph
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0
|
|
7
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*/
|
|
9
|
+
#include "ciph.h"
|
|
10
|
+
#include <sodium.h>
|
|
11
|
+
#include <stdint.h>
|
|
12
|
+
#include <stdlib.h>
|
|
13
|
+
#include <string.h>
|
|
14
|
+
#include <arpa/inet.h>
|
|
15
|
+
|
|
16
|
+
#define MAGIC "CIPH"
|
|
17
|
+
#define VERSION 2
|
|
18
|
+
|
|
19
|
+
#define SALT_LEN 16
|
|
20
|
+
#define KEY_LEN 32
|
|
21
|
+
#define NONCE_LEN 12
|
|
22
|
+
#define CHUNK (1024 * 1024)
|
|
23
|
+
|
|
24
|
+
static void die(const char *m) {
|
|
25
|
+
fprintf(stderr, "ciph: %s\n", m);
|
|
26
|
+
exit(1);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
int ciph_encrypt_stream(
|
|
30
|
+
FILE *in,
|
|
31
|
+
FILE *out,
|
|
32
|
+
const char *password,
|
|
33
|
+
int cipher,
|
|
34
|
+
const char *original_name
|
|
35
|
+
) {
|
|
36
|
+
if (sodium_init() < 0) die("sodium init failed");
|
|
37
|
+
|
|
38
|
+
uint8_t salt[SALT_LEN], data_key[KEY_LEN], derived[KEY_LEN];
|
|
39
|
+
randombytes_buf(salt, SALT_LEN);
|
|
40
|
+
randombytes_buf(data_key, KEY_LEN);
|
|
41
|
+
|
|
42
|
+
if (crypto_pwhash(
|
|
43
|
+
derived, KEY_LEN,
|
|
44
|
+
password, strlen(password),
|
|
45
|
+
salt,
|
|
46
|
+
crypto_pwhash_OPSLIMIT_MODERATE,
|
|
47
|
+
crypto_pwhash_MEMLIMIT_MODERATE,
|
|
48
|
+
crypto_pwhash_ALG_DEFAULT
|
|
49
|
+
) != 0) die("pwhash failed");
|
|
50
|
+
|
|
51
|
+
uint8_t nonce_key[NONCE_LEN];
|
|
52
|
+
randombytes_buf(nonce_key, NONCE_LEN);
|
|
53
|
+
|
|
54
|
+
uint8_t enc_data_key[KEY_LEN + crypto_aead_chacha20poly1305_ietf_ABYTES];
|
|
55
|
+
unsigned long long enc_key_len;
|
|
56
|
+
|
|
57
|
+
crypto_aead_chacha20poly1305_ietf_encrypt(
|
|
58
|
+
enc_data_key, &enc_key_len,
|
|
59
|
+
data_key, KEY_LEN,
|
|
60
|
+
NULL, 0, NULL,
|
|
61
|
+
nonce_key, derived
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
/* Header */
|
|
65
|
+
fwrite(MAGIC, 1, 4, out);
|
|
66
|
+
fputc(VERSION, out);
|
|
67
|
+
fputc(cipher, out);
|
|
68
|
+
fwrite(salt, 1, SALT_LEN, out);
|
|
69
|
+
fwrite(nonce_key, 1, NONCE_LEN, out);
|
|
70
|
+
|
|
71
|
+
/* Filename */
|
|
72
|
+
uint8_t name_len = 0;
|
|
73
|
+
if (original_name) {
|
|
74
|
+
size_t len = strlen(original_name);
|
|
75
|
+
if (len > 255) len = 255;
|
|
76
|
+
name_len = (uint8_t)len;
|
|
77
|
+
}
|
|
78
|
+
fputc(name_len, out);
|
|
79
|
+
if (name_len > 0)
|
|
80
|
+
fwrite(original_name, 1, name_len, out);
|
|
81
|
+
|
|
82
|
+
uint16_t ek = htons((uint16_t)enc_key_len);
|
|
83
|
+
fwrite(&ek, sizeof(uint16_t), 1, out);
|
|
84
|
+
fwrite(enc_data_key, 1, enc_key_len, out);
|
|
85
|
+
|
|
86
|
+
/* Stream encryption (FRAMED) */
|
|
87
|
+
uint8_t buf[CHUNK];
|
|
88
|
+
uint64_t idx = 0;
|
|
89
|
+
|
|
90
|
+
while (1) {
|
|
91
|
+
size_t r = fread(buf, 1, CHUNK, in);
|
|
92
|
+
if (r == 0) break;
|
|
93
|
+
|
|
94
|
+
uint8_t nonce[NONCE_LEN];
|
|
95
|
+
crypto_generichash(
|
|
96
|
+
nonce, NONCE_LEN,
|
|
97
|
+
(uint8_t*)&idx, sizeof(idx),
|
|
98
|
+
data_key, KEY_LEN
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
uint8_t outbuf[CHUNK + crypto_aead_chacha20poly1305_ietf_ABYTES];
|
|
102
|
+
unsigned long long outlen;
|
|
103
|
+
int ok;
|
|
104
|
+
|
|
105
|
+
if (cipher == CIPH_AES) {
|
|
106
|
+
ok = crypto_aead_aes256gcm_encrypt(
|
|
107
|
+
outbuf, &outlen, buf, r,
|
|
108
|
+
NULL, 0, NULL, nonce, data_key
|
|
109
|
+
);
|
|
110
|
+
} else {
|
|
111
|
+
ok = crypto_aead_chacha20poly1305_ietf_encrypt(
|
|
112
|
+
outbuf, &outlen, buf, r,
|
|
113
|
+
NULL, 0, NULL, nonce, data_key
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (ok != 0) die("encrypt failed");
|
|
118
|
+
|
|
119
|
+
uint32_t clen = htonl((uint32_t)outlen);
|
|
120
|
+
fwrite(&clen, sizeof(uint32_t), 1, out);
|
|
121
|
+
fwrite(outbuf, 1, outlen, out);
|
|
122
|
+
idx++;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
sodium_memzero(data_key, KEY_LEN);
|
|
126
|
+
sodium_memzero(derived, KEY_LEN);
|
|
127
|
+
return CIPH_OK;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
int ciph_decrypt_stream(
|
|
131
|
+
FILE *in,
|
|
132
|
+
FILE *out,
|
|
133
|
+
const char *password,
|
|
134
|
+
char *out_name,
|
|
135
|
+
size_t out_name_len
|
|
136
|
+
) {
|
|
137
|
+
if (sodium_init() < 0) die("sodium init failed");
|
|
138
|
+
|
|
139
|
+
char magic[4];
|
|
140
|
+
fread(magic, 1, 4, in);
|
|
141
|
+
if (memcmp(magic, MAGIC, 4)) die("bad magic");
|
|
142
|
+
|
|
143
|
+
int version = fgetc(in);
|
|
144
|
+
int cipher = fgetc(in);
|
|
145
|
+
if (version != VERSION) die("bad version");
|
|
146
|
+
|
|
147
|
+
uint8_t salt[SALT_LEN], nonce_key[NONCE_LEN];
|
|
148
|
+
fread(salt, 1, SALT_LEN, in);
|
|
149
|
+
fread(nonce_key, 1, NONCE_LEN, in);
|
|
150
|
+
|
|
151
|
+
uint8_t name_len = fgetc(in);
|
|
152
|
+
if (name_len > 0 && out_name && out_name_len > name_len) {
|
|
153
|
+
fread(out_name, 1, name_len, in);
|
|
154
|
+
out_name[name_len] = '\0';
|
|
155
|
+
} else if (name_len > 0) {
|
|
156
|
+
fseek(in, name_len, SEEK_CUR);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
uint16_t ek_len;
|
|
160
|
+
fread(&ek_len, sizeof(uint16_t), 1, in);
|
|
161
|
+
ek_len = ntohs(ek_len);
|
|
162
|
+
|
|
163
|
+
uint8_t enc_data_key[128];
|
|
164
|
+
fread(enc_data_key, 1, ek_len, in);
|
|
165
|
+
|
|
166
|
+
uint8_t derived[KEY_LEN], data_key[KEY_LEN];
|
|
167
|
+
if (crypto_pwhash(
|
|
168
|
+
derived, KEY_LEN,
|
|
169
|
+
password, strlen(password),
|
|
170
|
+
salt,
|
|
171
|
+
crypto_pwhash_OPSLIMIT_MODERATE,
|
|
172
|
+
crypto_pwhash_MEMLIMIT_MODERATE,
|
|
173
|
+
crypto_pwhash_ALG_DEFAULT
|
|
174
|
+
) != 0) die("pwhash failed");
|
|
175
|
+
|
|
176
|
+
if (crypto_aead_chacha20poly1305_ietf_decrypt(
|
|
177
|
+
data_key, NULL, NULL,
|
|
178
|
+
enc_data_key, ek_len,
|
|
179
|
+
NULL, 0,
|
|
180
|
+
nonce_key, derived
|
|
181
|
+
) != 0) {
|
|
182
|
+
fprintf(stderr, "ciph: wrong password or corrupted file\n");
|
|
183
|
+
return CIPH_ERR;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/* Stream decryption (FRAMED) */
|
|
187
|
+
uint8_t buf[CHUNK + crypto_aead_chacha20poly1305_ietf_ABYTES];
|
|
188
|
+
uint64_t idx = 0;
|
|
189
|
+
|
|
190
|
+
while (1) {
|
|
191
|
+
uint32_t clen_net;
|
|
192
|
+
if (fread(&clen_net, sizeof(uint32_t), 1, in) != 1)
|
|
193
|
+
break;
|
|
194
|
+
|
|
195
|
+
uint32_t clen = ntohl(clen_net);
|
|
196
|
+
if (clen > sizeof(buf)) {
|
|
197
|
+
fprintf(stderr, "ciph: corrupted chunk size\n");
|
|
198
|
+
return CIPH_ERR;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (fread(buf, 1, clen, in) != clen) {
|
|
202
|
+
fprintf(stderr, "ciph: truncated file\n");
|
|
203
|
+
return CIPH_ERR;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
uint8_t nonce[NONCE_LEN];
|
|
207
|
+
crypto_generichash(
|
|
208
|
+
nonce, NONCE_LEN,
|
|
209
|
+
(uint8_t*)&idx, sizeof(idx),
|
|
210
|
+
data_key, KEY_LEN
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
uint8_t outbuf[CHUNK];
|
|
214
|
+
unsigned long long outlen;
|
|
215
|
+
int ok;
|
|
216
|
+
|
|
217
|
+
if (cipher == CIPH_AES) {
|
|
218
|
+
ok = crypto_aead_aes256gcm_decrypt(
|
|
219
|
+
outbuf, &outlen, NULL,
|
|
220
|
+
buf, clen, NULL, 0, nonce, data_key
|
|
221
|
+
);
|
|
222
|
+
} else {
|
|
223
|
+
ok = crypto_aead_chacha20poly1305_ietf_decrypt(
|
|
224
|
+
outbuf, &outlen, NULL,
|
|
225
|
+
buf, clen, NULL, 0, nonce, data_key
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (ok != 0) {
|
|
230
|
+
fprintf(stderr, "ciph: integrity failure\n");
|
|
231
|
+
return CIPH_ERR;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
fwrite(outbuf, 1, outlen, out);
|
|
235
|
+
idx++;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
sodium_memzero(data_key, KEY_LEN);
|
|
239
|
+
sodium_memzero(derived, KEY_LEN);
|
|
240
|
+
return CIPH_OK;
|
|
241
|
+
}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ciph
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Fast, streaming file encryption for large media files and cloud uploads
|
|
5
|
+
Author-email: Ankit Chaubey <m.ankitchaubey@gmail.com>
|
|
6
|
+
License: Apache License 2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/ankit-chaubey/ciph
|
|
8
|
+
Project-URL: Source, https://github.com/ankit-chaubey/ciph
|
|
9
|
+
Project-URL: Issues, https://github.com/ankit-chaubey/ciph/issues
|
|
10
|
+
Keywords: encryption,cryptography,security,aes,chacha20,argon2,streaming,files,privacy
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Topic :: Security :: Cryptography
|
|
14
|
+
Classifier: Topic :: System :: Archiving :: Backup
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: Programming Language :: C
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
19
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
20
|
+
Classifier: Operating System :: Unix
|
|
21
|
+
Requires-Python: >=3.8
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: tqdm>=4.60.0
|
|
25
|
+
Dynamic: license-file
|
|
26
|
+
Dynamic: requires-python
|
|
27
|
+
|
|
28
|
+
# ciph
|
|
29
|
+
|
|
30
|
+
**ciph** is a fast, streaming file‑encryption tool built for **large media files** and **cloud uploads**. It uses modern, industry‑standard cryptography and is designed to safely encrypt files **larger than your system RAM**.
|
|
31
|
+
|
|
32
|
+
> Encrypt locally. Upload anywhere. Decrypt only when you trust the environment.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## ❓ Why ciph?
|
|
37
|
+
|
|
38
|
+
Most encryption tools load the entire file into memory before encrypting it. **ciph streams data in fixed-size chunks**, which means you can encrypt a **50 GB 4K video on a machine with only 2 GB of RAM**—smoothly and safely.
|
|
39
|
+
|
|
40
|
+
## ✨ Features
|
|
41
|
+
|
|
42
|
+
* 🔐 **Strong encryption** — AES‑256‑GCM or ChaCha20‑Poly1305
|
|
43
|
+
* 🔑 **Password protection** — Argon2id (memory‑hard key derivation)
|
|
44
|
+
* 🚀 **High performance** — streaming C core (1 MB chunks)
|
|
45
|
+
* 🧠 **Constant memory usage** — works with 10 GB+ files
|
|
46
|
+
* ⚙️ **Hardware‑aware** — AES‑NI when available, ChaCha fallback
|
|
47
|
+
* 🧪 **Integrity protected** — AEAD authentication on every chunk
|
|
48
|
+
* ☁️ **Cloud / Telegram safe** — encrypt before upload
|
|
49
|
+
* 🏷️ **Filename preserved** — original filename & extension are stored and restored on decryption
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## 🔐 Cryptographic Design
|
|
54
|
+
|
|
55
|
+
`ciph` uses a **hybrid (envelope) encryption model**, similar to what is used in modern secure storage systems:
|
|
56
|
+
|
|
57
|
+
1. A random **data key** encrypts the file in streaming mode.
|
|
58
|
+
2. Your password is hardened using **Argon2id**.
|
|
59
|
+
3. The data key is encrypted using the derived password key.
|
|
60
|
+
4. Every chunk is authenticated to detect tampering.
|
|
61
|
+
|
|
62
|
+
No custom crypto. No weak primitives.
|
|
63
|
+
|
|
64
|
+
5. The **original filename (without path)** is stored as encrypted metadata and automatically restored on decryption.
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## 🔒 Security Strength
|
|
69
|
+
|
|
70
|
+
| Component | Algorithm | Strength |
|
|
71
|
+
| -------------------------- | ---------------------------------------- | ------------ |
|
|
72
|
+
| File encryption | AES‑256‑GCM | 256‑bit |
|
|
73
|
+
| File encryption (fallback) | ChaCha20‑Poly1305 | 256‑bit |
|
|
74
|
+
| Password KDF | Argon2id | Memory‑hard |
|
|
75
|
+
| Integrity | AEAD | Tamper‑proof |
|
|
76
|
+
| Nonces | Key-derived per chunk (unique, no reuse) | No reuse |
|
|
77
|
+
|
|
78
|
+
### What this means
|
|
79
|
+
|
|
80
|
+
* Brute‑force attacks are **computationally infeasible**
|
|
81
|
+
* File corruption or tampering is **always detected**
|
|
82
|
+
* Encrypted files are safe on **any cloud platform**
|
|
83
|
+
* Losing the password means **data is unrecoverable**
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## 🚀 Quick Start (Build from Source)
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
git clone https://github.com/ankit-chaubey/ciph
|
|
91
|
+
cd ciph
|
|
92
|
+
make
|
|
93
|
+
pip install .
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## 📦 Installation
|
|
97
|
+
|
|
98
|
+
### Requirements
|
|
99
|
+
|
|
100
|
+
* Linux / Termux
|
|
101
|
+
* Python ≥ 3.8
|
|
102
|
+
* libsodium
|
|
103
|
+
|
|
104
|
+
### Install from PyPI
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
pip install ciph
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## 🚀 Usage
|
|
113
|
+
|
|
114
|
+
### Encrypt a file
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
ciph encrypt video.mp4
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Output:
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
video.mp4.ciph
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Decrypt a file
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
ciph decrypt video.mp4.ciph
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Output:
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
video.mp4
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
> The original filename and extension are automatically restored, even if the encrypted file was renamed.`
|
|
139
|
+
|
|
140
|
+
### Example workflow (Cloud / Telegram)
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
ciph encrypt movie.mkv
|
|
144
|
+
# upload movie.mkv.ciph anywhere
|
|
145
|
+
# share the password securely
|
|
146
|
+
|
|
147
|
+
ciph decrypt movie.mkv.ciph
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## 📝 File Format (V2)
|
|
153
|
+
|
|
154
|
+
| Offset | Size | Description |
|
|
155
|
+
| ------ | ---- | -------------------------------------- |
|
|
156
|
+
| 0 | 4 | Magic bytes (`CIPH`) |
|
|
157
|
+
| 4 | 1 | Format version |
|
|
158
|
+
| 5 | 1 | Cipher mode (1 = AES, 2 = ChaCha) |
|
|
159
|
+
| 6 | 16 | Argon2 salt |
|
|
160
|
+
| 22 | 12 | Key nonce |
|
|
161
|
+
| 34 | 1 | Filename length (N) |
|
|
162
|
+
| 35 | N | Original filename (UTF‑8) |
|
|
163
|
+
| 35+N | 2 | Encrypted data‑key length |
|
|
164
|
+
| … | … | Encrypted data key + encrypted payload |
|
|
165
|
+
|
|
166
|
+
## 📊 Performance
|
|
167
|
+
|
|
168
|
+
* Processes data in **1 MB chunks**
|
|
169
|
+
* Cryptography handled in **C (libsodium)**
|
|
170
|
+
* Python used only for CLI orchestration
|
|
171
|
+
* Typical throughput: **hundreds of MB/s** (CPU‑bound)
|
|
172
|
+
|
|
173
|
+
Encryption is usually faster than your internet upload speed.
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## ⚠️ Limitations (v0.1.0)
|
|
178
|
+
|
|
179
|
+
* Linux / Termux only
|
|
180
|
+
* No resume support yet
|
|
181
|
+
* Progress bar shows start → finish (stream handled in C)
|
|
182
|
+
* Password‑based encryption only (public‑key mode planned)
|
|
183
|
+
* Filename metadata is visible (content remains fully encrypted)
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## 🧑💻 Author & Project
|
|
188
|
+
|
|
189
|
+
**ciph** is **designed, developed, and maintained** by
|
|
190
|
+
|
|
191
|
+
[**Ankit Chaubey (@ankit‑chaubey)**](https://github.com/ankit-chaubey)
|
|
192
|
+
|
|
193
|
+
GitHub Repository:
|
|
194
|
+
👉 **[https://github.com/ankit-chaubey/ciph](https://github.com/ankit-chaubey/ciph)**
|
|
195
|
+
|
|
196
|
+
The project focuses on building **secure, efficient, and practical cryptographic tools** for real‑world usage, especially for media files and cloud storage.
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## 📜 License
|
|
201
|
+
|
|
202
|
+
Apache License 2.0
|
|
203
|
+
|
|
204
|
+
Copyright © 2026 Ankit Chaubey
|
|
205
|
+
|
|
206
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
|
|
207
|
+
You may obtain a copy of the License at:
|
|
208
|
+
|
|
209
|
+
[https://www.apache.org/licenses/LICENSE-2.0](https://www.apache.org/licenses/LICENSE-2.0)
|
|
210
|
+
|
|
211
|
+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,
|
|
212
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
213
|
+
See the License for the specific language governing permissions and limitations under the License.
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
## 🔮 Roadmap
|
|
218
|
+
|
|
219
|
+
Planned future improvements:
|
|
220
|
+
|
|
221
|
+
* Parallel chunk encryption
|
|
222
|
+
* Resume / partial decryption
|
|
223
|
+
* Public‑key encryption mode
|
|
224
|
+
* Real‑time progress callbacks
|
|
225
|
+
* Prebuilt wheels (manylinux)
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## ⚠️ Disclaimer
|
|
230
|
+
|
|
231
|
+
This tool uses strong cryptography.
|
|
232
|
+
|
|
233
|
+
If you forget your password, **your data cannot be recovered**.
|
|
234
|
+
|
|
235
|
+
Use responsibly.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
MANIFEST.in
|
|
3
|
+
Makefile
|
|
4
|
+
README.md
|
|
5
|
+
ciph.c
|
|
6
|
+
ciph.h
|
|
7
|
+
pyproject.toml
|
|
8
|
+
setup.py
|
|
9
|
+
ciph/__init__.py
|
|
10
|
+
ciph/cli.py
|
|
11
|
+
ciph.egg-info/PKG-INFO
|
|
12
|
+
ciph.egg-info/SOURCES.txt
|
|
13
|
+
ciph.egg-info/dependency_links.txt
|
|
14
|
+
ciph.egg-info/entry_points.txt
|
|
15
|
+
ciph.egg-info/requires.txt
|
|
16
|
+
ciph.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
tqdm>=4.60.0
|
ciph-0.1.0/ciph.h
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* ciph
|
|
3
|
+
* © 2026 Ankit Chaubey (@ankit-chaubey)
|
|
4
|
+
* https://github.com/ankit-chaubey/ciph
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0
|
|
7
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*/
|
|
9
|
+
#ifndef CIPH_H
|
|
10
|
+
#define CIPH_H
|
|
11
|
+
|
|
12
|
+
#include <stdio.h>
|
|
13
|
+
|
|
14
|
+
#define CIPH_AES 1
|
|
15
|
+
#define CIPH_CHACHA 2
|
|
16
|
+
|
|
17
|
+
#define CIPH_OK 0
|
|
18
|
+
#define CIPH_ERR -1
|
|
19
|
+
|
|
20
|
+
int ciph_encrypt_stream(
|
|
21
|
+
FILE *in,
|
|
22
|
+
FILE *out,
|
|
23
|
+
const char *password,
|
|
24
|
+
int cipher,
|
|
25
|
+
const char *original_name
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
int ciph_decrypt_stream(
|
|
29
|
+
FILE *in,
|
|
30
|
+
FILE *out,
|
|
31
|
+
const char *password,
|
|
32
|
+
char *out_name, // buffer (>=256 bytes)
|
|
33
|
+
size_t out_name_len
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
#endif
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "ciph"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Fast, streaming file encryption for large media files and cloud uploads"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
license = { text = "Apache License 2.0" }
|
|
12
|
+
|
|
13
|
+
authors = [
|
|
14
|
+
{ name = "Ankit Chaubey", email = "m.ankitchaubey@gmail.com" }
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
dependencies = [
|
|
18
|
+
"tqdm>=4.60.0",
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
keywords = [
|
|
22
|
+
"encryption", "cryptography", "security", "aes", "chacha20",
|
|
23
|
+
"argon2", "streaming", "files", "privacy"
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
classifiers = [
|
|
27
|
+
"Development Status :: 4 - Beta",
|
|
28
|
+
"Intended Audience :: Developers",
|
|
29
|
+
"Topic :: Security :: Cryptography",
|
|
30
|
+
"Topic :: System :: Archiving :: Backup",
|
|
31
|
+
"License :: OSI Approved :: Apache Software License",
|
|
32
|
+
"Programming Language :: C",
|
|
33
|
+
"Programming Language :: Python :: 3",
|
|
34
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
35
|
+
"Operating System :: POSIX :: Linux",
|
|
36
|
+
"Operating System :: Unix"
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
[project.urls]
|
|
40
|
+
Homepage = "https://github.com/ankit-chaubey/ciph"
|
|
41
|
+
Source = "https://github.com/ankit-chaubey/ciph"
|
|
42
|
+
Issues = "https://github.com/ankit-chaubey/ciph/issues"
|
|
43
|
+
|
|
44
|
+
[project.scripts]
|
|
45
|
+
ciph = "ciph.cli:main"
|
ciph-0.1.0/setup.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
setup(
|
|
4
|
+
name="ciph",
|
|
5
|
+
version="0.1.0",
|
|
6
|
+
description="Fast streaming encryption for large media files",
|
|
7
|
+
long_description=open("README.md").read(),
|
|
8
|
+
long_description_content_type="text/markdown",
|
|
9
|
+
packages=find_packages(),
|
|
10
|
+
include_package_data=True,
|
|
11
|
+
entry_points={
|
|
12
|
+
"console_scripts": [
|
|
13
|
+
"ciph=ciph.cli:main",
|
|
14
|
+
]
|
|
15
|
+
},
|
|
16
|
+
python_requires=">=3.8",
|
|
17
|
+
)
|
ciph-0.0.0/PKG-INFO
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: ciph
|
|
3
|
-
Version: 0.0.0
|
|
4
|
-
Summary: Placeholder package reserved for future development.
|
|
5
|
-
Author-email: Ankit Chaubey <m.ankitchaubey@gmail.com>
|
|
6
|
-
License: MIT
|
|
7
|
-
Project-URL: Homepage, https://github.com/ankit-chaubey/ciph
|
|
8
|
-
Project-URL: Source, https://github.com/ankit-chaubey/ciph
|
|
9
|
-
Project-URL: Issues, https://github.com/ankit-chaubey/ciph/issues
|
|
10
|
-
Keywords: encryption,security,crypto
|
|
11
|
-
Classifier: Programming Language :: Python :: 3
|
|
12
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
-
Classifier: Operating System :: OS Independent
|
|
14
|
-
Requires-Python: >=3.8
|
|
15
|
-
Description-Content-Type: text/markdown
|
ciph-0.0.0/ciph/__init__.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# welcome to ciph
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: ciph
|
|
3
|
-
Version: 0.0.0
|
|
4
|
-
Summary: Placeholder package reserved for future development.
|
|
5
|
-
Author-email: Ankit Chaubey <m.ankitchaubey@gmail.com>
|
|
6
|
-
License: MIT
|
|
7
|
-
Project-URL: Homepage, https://github.com/ankit-chaubey/ciph
|
|
8
|
-
Project-URL: Source, https://github.com/ankit-chaubey/ciph
|
|
9
|
-
Project-URL: Issues, https://github.com/ankit-chaubey/ciph/issues
|
|
10
|
-
Keywords: encryption,security,crypto
|
|
11
|
-
Classifier: Programming Language :: Python :: 3
|
|
12
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
-
Classifier: Operating System :: OS Independent
|
|
14
|
-
Requires-Python: >=3.8
|
|
15
|
-
Description-Content-Type: text/markdown
|
ciph-0.0.0/pyproject.toml
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
[build-system]
|
|
2
|
-
requires = ["setuptools>=61.0"]
|
|
3
|
-
build-backend = "setuptools.build_meta"
|
|
4
|
-
|
|
5
|
-
[project]
|
|
6
|
-
name = "ciph" # change to "vylt" if needed
|
|
7
|
-
version = "0.0.0"
|
|
8
|
-
description = "Placeholder package reserved for future development."
|
|
9
|
-
readme = "README.md"
|
|
10
|
-
requires-python = ">=3.8"
|
|
11
|
-
license = { text = "MIT" }
|
|
12
|
-
|
|
13
|
-
authors = [
|
|
14
|
-
{ name = "Ankit Chaubey", email = "m.ankitchaubey@gmail.com" }
|
|
15
|
-
]
|
|
16
|
-
|
|
17
|
-
keywords = ["encryption", "security", "crypto"]
|
|
18
|
-
classifiers = [
|
|
19
|
-
"Programming Language :: Python :: 3",
|
|
20
|
-
"License :: OSI Approved :: MIT License",
|
|
21
|
-
"Operating System :: OS Independent"
|
|
22
|
-
]
|
|
23
|
-
|
|
24
|
-
[project.urls]
|
|
25
|
-
Homepage = "https://github.com/ankit-chaubey/ciph"
|
|
26
|
-
Source = "https://github.com/ankit-chaubey/ciph"
|
|
27
|
-
Issues = "https://github.com/ankit-chaubey/ciph/issues"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|