Skip to main content

saad_tools

مكتبة بايثون صغيرة للتشفير الموثّق وتخزين الأسرار في خزنة محمية بكلمة مرور.

تنبيه أمني مهم: التشفير يحمي البيانات والمفاتيح المخزنة، لكنه لا يستطيع منع نسخ كود بايثون الذي يجب توزيعه وتشغيله على جهاز المستخدم. إذا كان الهدف حماية منطق تجاري سري، فالحل الأقوى هو إبقاء المنطق على خادم API وعدم شحنه إلى العميل، أو استخدام خدمة إدارة أسرار/وحدة HSM. لا تضع كلمة مرور الخزنة داخل الكود أو مستودع Git.

التثبيت

pip install saad_tools

تشفير البيانات

from saad_tools import decrypt_text, encrypt_text, generate_key

key = generate_key()  # خزّنها في مدير أسرار، لا في المصدر
ciphertext = encrypt_text("رسالة سرية", key)
plaintext = decrypt_text(ciphertext, key)

التشفير المستخدم هو AES-256-GCM مع nonce عشوائي لكل عملية، لذلك يكتشف التعديل أو كلمة المرور/المفتاح الخاطئ.

خزنة الأسرار

from saad_tools import Vault

vault = Vault("~/.config/myapp/vault.json", "كلمة مرور طويلة وفريدة", create=True)
vault.set("database_password", "...secret...")
password = Vault("~/.config/myapp/vault.json", "كلمة مرور طويلة وفريدة").get("database_password")

الخزنة تستخدم scrypt لاشتقاق مفتاح من كلمة المرور، ثم AES-256-GCM لتشفير المحتوى. لا تُحفظ كلمة المرور في الملف. يحاول البرنامج جعل صلاحيات الملف 0600 على الأنظمة التي تدعم ذلك.

تطوير محلي

python -m pip install -e ".[test]"
pytest
python -m build

الحالة

الإصدار الحالي 0.1.0 تجريبي. قبل استخدامه في إنتاج حساس، راجع إدارة كلمات المرور، النسخ الاحتياطي، صلاحيات نظام الملفات، وسياسة تدوير المفاتيح. لا تحذف الخزنة الأصلية قبل اختبار النسخة الاحتياطية.

الترخيص

MIT

Release files for saad-crypto 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for saad-crypto 0.1.0
File Size Uploaded
saad_crypto-0.1.0.tar.gz 6.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for saad-crypto 0.1.0
File Interpreter ABI Platform
saad_crypto-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 12.1 kB

Release files / saad_crypto-0.1.0.tar.gz

Download URL saad_crypto-0.1.0.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
5b571ac5e19237c61c77046bc467d93922014bc35f831b8b9cf23fef83015556
BLAKE2b-256 checksum
How to use checksums
c9a435cd473956aa0d734df8aec7791a6524389e0a6fcbd72e782062448d30d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.4

Release files / saad_crypto-0.1.0-py3-none-any.whl

Download URL saad_crypto-0.1.0-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1e015d8903a4ce1a5a959a196fd3501f3332a1555dcf2ada116a50481367521c
BLAKE2b-256 checksum
How to use checksums
44a521c5bc9d2c3fe5263bba10216618b13f36122ed34a71d7c74a4a0b60612a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.4

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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