deathCode 1.0.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.
deathCode/__init__.py
ADDED
deathCode/encryptor.py
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
import struct
|
|
4
|
+
from Crypto.Cipher import AES
|
|
5
|
+
from Crypto.Hash import SHA256
|
|
6
|
+
from Crypto.Random import get_random_bytes
|
|
7
|
+
import argparse
|
|
8
|
+
|
|
9
|
+
# ========== التشفير ==========
|
|
10
|
+
|
|
11
|
+
def encrypt_file(file_path, password):
|
|
12
|
+
"""تشفير ملف وتحويله إلى .dc"""
|
|
13
|
+
output_path = file_path + ".dc"
|
|
14
|
+
|
|
15
|
+
# تحويل كلمة المرور إلى مفتاح 32 بايت
|
|
16
|
+
key = SHA256.new(password.encode()).digest()
|
|
17
|
+
|
|
18
|
+
# إنشاء IV عشوائي
|
|
19
|
+
iv = get_random_bytes(16)
|
|
20
|
+
|
|
21
|
+
cipher = AES.new(key, AES.MODE_CBC, iv)
|
|
22
|
+
|
|
23
|
+
with open(file_path, "rb") as f:
|
|
24
|
+
plaintext = f.read()
|
|
25
|
+
|
|
26
|
+
# Padding لجعل النص مضاعف 16 بايت
|
|
27
|
+
pad_len = 16 - (len(plaintext) % 16)
|
|
28
|
+
plaintext += bytes([pad_len]) * pad_len
|
|
29
|
+
|
|
30
|
+
ciphertext = cipher.encrypt(plaintext)
|
|
31
|
+
|
|
32
|
+
with open(output_path, "wb") as f:
|
|
33
|
+
f.write(iv + ciphertext) # نحفظ IV مع الملف
|
|
34
|
+
|
|
35
|
+
print(f"[✓] تم التشفير: {file_path} -> {output_path}")
|
|
36
|
+
return output_path
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def decrypt_file(file_path, password):
|
|
40
|
+
"""فك تشفير ملف .dc"""
|
|
41
|
+
if not file_path.endswith(".dc"):
|
|
42
|
+
print("[✗] الملف مو بصيغة .dc")
|
|
43
|
+
return None
|
|
44
|
+
|
|
45
|
+
# استخراج اسم الملف الأصلي
|
|
46
|
+
original_path = file_path[:-3]
|
|
47
|
+
|
|
48
|
+
key = SHA256.new(password.encode()).digest()
|
|
49
|
+
|
|
50
|
+
with open(file_path, "rb") as f:
|
|
51
|
+
iv = f.read(16) # أول 16 بايت هي IV
|
|
52
|
+
ciphertext = f.read()
|
|
53
|
+
|
|
54
|
+
cipher = AES.new(key, AES.MODE_CBC, iv)
|
|
55
|
+
plaintext = cipher.decrypt(ciphertext)
|
|
56
|
+
|
|
57
|
+
# إزالة padding
|
|
58
|
+
pad_len = plaintext[-1]
|
|
59
|
+
plaintext = plaintext[:-pad_len]
|
|
60
|
+
|
|
61
|
+
with open(original_path, "wb") as f:
|
|
62
|
+
f.write(plaintext)
|
|
63
|
+
|
|
64
|
+
print(f"[✓] تم فك التشفير: {file_path} -> {original_path}")
|
|
65
|
+
return original_path
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def encrypt_folder(folder_path, password):
|
|
69
|
+
"""تشفير كل الملفات في مجلد"""
|
|
70
|
+
count = 0
|
|
71
|
+
for root, dirs, files in os.walk(folder_path):
|
|
72
|
+
for file in files:
|
|
73
|
+
file_path = os.path.join(root, file)
|
|
74
|
+
if not file_path.endswith(".dc"):
|
|
75
|
+
encrypt_file(file_path, password)
|
|
76
|
+
count += 1
|
|
77
|
+
print(f"\n[✓] تم تشفير {count} ملف في المجلد: {folder_path}")
|
|
78
|
+
return count
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def decrypt_folder(folder_path, password):
|
|
82
|
+
"""فك تشفير كل ملفات .dc في مجلد"""
|
|
83
|
+
count = 0
|
|
84
|
+
for root, dirs, files in os.walk(folder_path):
|
|
85
|
+
for file in files:
|
|
86
|
+
if file.endswith(".dc"):
|
|
87
|
+
file_path = os.path.join(root, file)
|
|
88
|
+
decrypt_file(file_path, password)
|
|
89
|
+
count += 1
|
|
90
|
+
print(f"\n[✓] تم فك تشفير {count} ملف في المجلد: {folder_path}")
|
|
91
|
+
return count
|
|
92
|
+
|
|
93
|
+
def main():
|
|
94
|
+
parser = argparse.ArgumentParser(description="DeathCode - DC Encryption Tool")
|
|
95
|
+
parser.add_argument("action", choices=["encrypt", "decrypt", "encrypt-folder", "decrypt-folder"],
|
|
96
|
+
help="الإجراء المطلوب")
|
|
97
|
+
parser.add_argument("path", help="مسار الملف أو المجلد")
|
|
98
|
+
parser.add_argument("--password", "-p", required=True, help="كلمة المرور")
|
|
99
|
+
|
|
100
|
+
args = parser.parse_args()
|
|
101
|
+
|
|
102
|
+
if args.action == "encrypt":
|
|
103
|
+
encrypt_file(args.path, args.password)
|
|
104
|
+
elif args.action == "decrypt":
|
|
105
|
+
decrypt_file(args.path, args.password)
|
|
106
|
+
elif args.action == "encrypt-folder":
|
|
107
|
+
encrypt_folder(args.path, args.password)
|
|
108
|
+
elif args.action == "decrypt-folder":
|
|
109
|
+
decrypt_folder(args.path, args.password)
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
if __name__ == "__main__":
|
|
113
|
+
main()
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: deathCode
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: مكتبة تشفير ملفات قوية (DC Encryption)
|
|
5
|
+
Author: DeathCode
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
+
Requires-Python: >=3.7
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
Requires-Dist: pycryptodome>=3.19.0
|
|
11
|
+
Dynamic: author
|
|
12
|
+
Dynamic: classifier
|
|
13
|
+
Dynamic: description
|
|
14
|
+
Dynamic: description-content-type
|
|
15
|
+
Dynamic: requires-dist
|
|
16
|
+
Dynamic: requires-python
|
|
17
|
+
Dynamic: summary
|
|
18
|
+
|
|
19
|
+
# DeathCode - DC Encryption
|
|
20
|
+
|
|
21
|
+
مكتبة تشفير ملفات قوية باستخدام AES-256-CBC
|
|
22
|
+
|
|
23
|
+
## التثبيت
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pip install deathCode
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
deathCode/__init__.py,sha256=UzEM6ZbOSd55vGwuwHoO__cEDRVmv2KFzgCaskPJ0Ac,132
|
|
2
|
+
deathCode/encryptor.py,sha256=r-IGO40rfnLXytELXowZJ-eszzJLBK9C6EFGGWtNIac,3766
|
|
3
|
+
deathcode-1.0.0.dist-info/METADATA,sha256=33qCuOKo5JDx7rD0DxXDvZDpqxHkv18TybcpX0o0EJE,669
|
|
4
|
+
deathcode-1.0.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
5
|
+
deathcode-1.0.0.dist-info/entry_points.txt,sha256=2YPrRclb9JfG0ihowciH4asGzf6dV_T4FJ-a537VUlM,52
|
|
6
|
+
deathcode-1.0.0.dist-info/top_level.txt,sha256=gvVzLgL-wKTOMQ_OPy_xLAGsMFn5MuYHtXrzy0ex7ZY,10
|
|
7
|
+
deathcode-1.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
deathCode
|