التجزئة/التشفير
PBKDF2 Hash + Verify
اشتقاق مفتاح عبر PBKDF2 (RFC 8018) من كلمة مرور، باستخدام HMAC-SHA1/256/384/512 وعدد تكرارات قابل للتخصيص.
PBKDF2 (RFC 8018) applies HMAC to a password and salt repeatedly to deliberately slow down computation — it's the oldest of the standardized algorithms for password hashing and encryption key derivation.
How to use it
- Derive: enter a password, pick an HMAC algorithm (SHA-1/256/384/512), and set the iteration count to get a derived key of the requested length.
- Verify: paste a password and an existing PBKDF2 hash to check whether they match, without recomputing it manually.
- More iterations means slower, more secure computation — tune the value to your server's response-time budget.
Common uses
- Deriving an encryption key from a user's password for a file container or a custom protocol.
- Checking a PBKDF2 implementation for compatibility across programming languages (the parameters must match exactly).
- Hashing passwords in systems that require a FIPS-compliant algorithm (PBKDF2 is NIST-approved).
Things to keep in mind
Unlike bcrypt and Argon2, PBKDF2 isn't memory-hard — it only requires CPU time, so it's less resistant to attacks on GPUs with many parallel compute units.
The recommended iteration count rises over time in NIST and OWASP guidance as hardware gets faster — check against current recommendations periodically.
الأسئلة الشائعة
كيف يؤثر عدد التكرارات (iterations) على الأمان والأداء؟
زيادة عدد التكرارات ترفع تكلفة حساب كل تخمين على المهاجم فتزيد الأمان، لكنها في المقابل تبطئ عملية الاشتقاق الشرعية أيضًا؛ لذا يجب اختيار قيمة تعكس توازنًا مناسبًا حسب قدرة الجهاز.
ما دور الملح (salt) في PBKDF2؟
الملح قيمة عشوائية فريدة تُضاف إلى كلمة المرور قبل الاشتقاق، وتمنع استخدام جداول تخمين جاهزة (rainbow tables) وتضمن أن نفس كلمة المرور تنتج هاشات مختلفة لمستخدمين مختلفين.
أين تُستخدم PBKDF2 عادةً؟
تُستخدم لاشتقاق مفاتيح تشفير من كلمات مرور (مثلًا في AES) ولتجزئة كلمات المرور للتخزين، عبر تطبيق دالة HMAC بشكل متكرر لجعل عملية الاشتقاق أبطأ عمدًا أمام هجمات القوة الغاشمة.
هل يهم اختيار دالة التجزئة الأساسية التي يستخدمها PBKDF2؟
نعم. غالبًا ما استخدمت التطبيقات القديمة HMAC-SHA1 افتراضيًا — وهذا ليس ثغرة حرجة ضمن بنية HMAC، لكن الإرشادات الحديثة توصي بوضوح باستخدام HMAC-SHA256 أو أقوى، لهامش أمان أكبر دون خسارة ملحوظة في السرعة.
أين يُستخدم PBKDF2 أيضًا غير تخزين كلمات المرور؟
يُستخدم PBKDF2 على نطاق واسع لاشتقاق مفاتيح تشفير من كلمات مرور — مثلًا في WPA2/WPA3 لشبكات Wi-Fi، وفي العديد من صيغ حاويات الملفات المشفّرة.