ciph 0.0.0__py3-none-any.whl → 0.1.0__py3-none-any.whl

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/__init__.py CHANGED
@@ -1 +1 @@
1
- # welcome to ciph
1
+ __version__ = "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()
@@ -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,8 @@
1
+ ciph/__init__.py,sha256=kUR5RAFc7HCeiqdlX36dZOHkUI5wI6V_43RpEcD8b-0,22
2
+ ciph/cli.py,sha256=xqYDleXrvH7Ofu4L4K5GkUsP5fnKPYXWjJavk7Szbco,2748
3
+ ciph-0.1.0.dist-info/licenses/LICENSE,sha256=wIAeYhitIddhNGFIO7yoUMtu5FuHLn734sVnGI33J14,628
4
+ ciph-0.1.0.dist-info/METADATA,sha256=OheBb-1mXpfPr20MA-gfKU8MWP6e6FdlQV2KDUBPUx8,7153
5
+ ciph-0.1.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
6
+ ciph-0.1.0.dist-info/entry_points.txt,sha256=0OC_DA7tkD2MSCIrXMOZ-wm6G_zKozrI54w2ATEb0W8,39
7
+ ciph-0.1.0.dist-info/top_level.txt,sha256=_VGthmGuuNhqV4Y8z_PpGm8U9wxfKq78RQMo4IpnMh0,5
8
+ ciph-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ ciph = ciph.cli:main
@@ -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.
@@ -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
@@ -1,5 +0,0 @@
1
- ciph/__init__.py,sha256=_bSj0I8bgLEogZTOPu1HcSf9iqm-WqZXV7FUQe7HC94,18
2
- ciph-0.0.0.dist-info/METADATA,sha256=Qf7itUdPYMReH0jH5nQdxCuBrHeYAzxbmc7PJQ-cKzI,610
3
- ciph-0.0.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
4
- ciph-0.0.0.dist-info/top_level.txt,sha256=_VGthmGuuNhqV4Y8z_PpGm8U9wxfKq78RQMo4IpnMh0,5
5
- ciph-0.0.0.dist-info/RECORD,,
File without changes