← All tasks
🧮
Advanced

Write a Constant-Time String Comparison

⏱ 3 min ⭐ 90 XP 🔁 3 attempts allowed

What you'll do

Write the PHP expression that safely compares two secret strings (like a token) in constant time.

Scenario

A naive '==' comparison of an API token is vulnerable to a timing attack that reveals the correct value character by character.

Ready to try it?

Create a free account and subscribe to take "Write a Constant-Time String Comparison". Earn 90 XP and track your internship progress.

Already have an account? Sign in