التجزئة/التشفير
TOTP Generator/Verifier
كلمات مرور لمرة واحدة قائمة على الوقت (TOTP، RFC 6238) — توليد الرمز الحالي من سر (secret) والتحقق من رمز مُدخل مع تحمل انحراف الساعة.
------
TOTP (Time-based One-Time Password, RFC 6238) is a two-factor authentication algorithm that generates a one-time code from a secret and the current time. It's exactly what runs under the hood in Google Authenticator, Authy, and similar apps.
How to use it
- Generate: paste a secret key (usually Base32, the same one encoded in a 2FA setup QR code) and the tool shows the current 6-digit code along with the time left before it changes.
- Verify: enter a secret and a code from an authenticator app to check whether they match.
- Verification tolerates a small amount of clock drift — it accepts a code from a neighboring time step, not just the current one.
Common uses
- Debugging your own 2FA implementation on the backend — checking that the server generates and accepts codes correctly.
- Manually generating a code for an account when you don't have your phone with the authenticator app handy.
- Figuring out why an app's code is being rejected by the server (usually the cause is a clock out of sync).
Things to keep in mind
A TOTP code is only valid for a short window (usually 30 seconds) — that time limit is the main protection, not the secret alone.
Code accuracy depends directly on the device's clock being synced; a noticeable clock drift is the most common cause of rejected 2FA codes.
مقالة عن هذه الأداة: TOTP: كيف تعمل الرموز أحادية الاستخدام في تطبيقات المصادقة
الأسئلة الشائعة
ما هو المعيار الذي تعتمد عليه هذه الأداة في توليد الرموز؟
تعتمد الأداة على معيار RFC 6238 (TOTP)، الذي يشتق رمزًا لمرة واحدة من سر مشترك ووقت حالي عبر HMAC، وهو ما تستخدمه معظم تطبيقات المصادقة الثنائية.
لماذا يتغير الرمز كل 30 ثانية؟
يُقسَّم الوقت إلى خطوات ثابتة (period)، عادة 30 ثانية، ويُشتق رمز جديد لكل خطوة زمنية؛ هذا التدوير يحد من صلاحية الرمز المسروق أو المُعترَض إلى فترة قصيرة جدًا.
لماذا يفشل التحقق من الرمز رغم إدخاله بشكل صحيح؟
غالبًا يعود السبب إلى عدم تزامن ساعة الجهاز؛ لأن التوليد يعتمد على الوقت الحالي، فأي انحراف كبير في ساعة الجهاز عن الوقت الفعلي (عادة يُصحَّح عبر NTP) يجعل الرمز غير صالح حتى ضمن نافذة التسامح.
هل يحمي TOTP من التصيّد الاحتيالي؟
ليس بشكل كامل. إذا أدخلت الضحية كلمة المرور ورمز TOTP الحالي على موقع مزيّف، يمكن للمهاجم استخدام كلتا القيمتين فورًا على الموقع الحقيقي طالما الرمز لا يزال صالحًا. لا يحمي من هذا الهجوم الفوري سوى المفاتيح الصلبة وفق معيار FIDO2/WebAuthn.
لماذا يقبل الخادم الفترة الزمنية السابقة أيضًا، لا الحالية فقط؟
هذا يعوّض عن التأخير الشبكي الطفيف بين توليد الرمز على الهاتف واللحظة التي يستلمه فيها الخادم ويتحقّق منه. بدون هذا الهامش، قد تُرفض رموز صحيحة أحيانًا بسبب تأخير عادي من بضع ثوانٍ.