التجزئة/التشفير
AES Encrypt/Decrypt
تشفير وفك تشفير النص باستخدام AES-GCM أو AES-CBC باستخدام كلمة مرور (المفتاح مُشتق عبر PBKDF2).
AES is the standard for symmetric encryption: the same password is used to both encrypt and decrypt. This tool derives an encryption key from your password with PBKDF2 and encrypts text with AES-GCM or AES-CBC — all locally in your browser.
How to use it
- Encrypt: enter text and a password, pick a mode (GCM or CBC), and get an encrypted result along with the parameters (salt, IV) needed to decrypt it later.
- Decrypt: paste the encrypted text and the same password to get the original back.
- AES-GCM is the recommended default: it encrypts and verifies data integrity at the same time (authenticated encryption).
Common uses
- Encrypting sensitive text before storing it or sending it over an untrusted channel.
- Checking that an AES encryption implementation matches across different languages or libraries.
- A teaching example for understanding the difference between the GCM and CBC encryption modes.
Things to keep in mind
The IV (initialization vector) must be unique for every encryption performed with the same key — reusing a key+IV pair in GCM completely breaks the encryption's security.
AES-CBC without a separate integrity check (a MAC) is vulnerable to ciphertext-tampering attacks — that's why GCM, which combines encryption and authentication in one mode, is the safer default.
الأسئلة الشائعة
لماذا يُفضَّل وضع AES-GCM على AES-CBC؟
AES-GCM يوفر تشفيرًا موثّقًا (authenticated encryption) يكتشف أي تلاعب بالبيانات المشفرة، بينما AES-CBC يوفر السرية فقط دون التحقق من سلامة البيانات، لذا يُنصح باستخدام GCM ما لم يوجد سبب محدد لاستخدام CBC.
ما خطورة إعادة استخدام نفس الـ IV/nonce مع نفس المفتاح؟
إعادة استخدام نفس الـ IV مع نفس المفتاح تُضعف الحماية بشكل خطير وقد تكشف معلومات عن النص الأصلي أو تسمح بتزوير البيانات في وضع GCM، لذا يجب توليد IV جديد وفريد مع كل عملية تشفير.
لماذا لا تُستخدم كلمة المرور مباشرة كمفتاح تشفير؟
كلمة المرور تُشتق إلى مفتاح تشفير عبر PBKDF2 بدلًا من استخدامها مباشرة، لأن هذا الاشتقاق يضيف ملحًا وتكرارات تجعل تخمين المفتاح من كلمة المرور أصعب بكثير.
لماذا لا يُنصَح باستخدام وضع ECB؟
يشفّر ECB كل كتلة بشكل مستقل ومتماثل، لذا تنتج الكتل المتطابقة من النص الأصلي كتلًا متطابقة من النص المشفَّر — وهذا يكشف بنية البيانات (مثلًا، تبقى الأنماط المتكرّرة في صورة ما ظاهرة حتى بعد التشفير). يحلّ CBC أو GCM مع IV فريد هذه المشكلة.
ماذا يحدث عند إعادة استخدام نفس IV مع نفس المفتاح؟
بالنسبة لـ GCM، هذا خطأ فادح — إذ تؤدي إعادة استخدام زوج المفتاح وIV إلى تقويض سرّية وأصالة التشفير بالكامل. يجب أن يكون IV فريدًا دائمًا مع كل عملية تشفير بنفس المفتاح.